From 5ba028c179701843a3c3e1d0b10919c04c233912 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Wed, 12 Mar 2014 09:31:06 -0700 Subject: [PATCH] DBStress cleanup Summary: *) fixed the comment *) constant 1 was not casted to 64-bit, which (I think) might cause overflow if we shift it too much *) default prefix size to be 7, like it was before Test Plan: compiled Reviewers: ljin Reviewed By: ljin CC: leveldb Differential Revision: https://reviews.facebook.net/D16827 --- tools/db_crashtest.py | 2 +- tools/db_crashtest2.py | 2 +- tools/db_stress.cc | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index e4774e557..16603cfd6 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -94,7 +94,7 @@ def main(argv): --max_bytes_for_level_base=10485760 --filter_deletes=%s --memtablerep=prefix_hash - --prefix_size=2 + --prefix_size=7 """ % (ops_per_thread, threads, write_buf_size, diff --git a/tools/db_crashtest2.py b/tools/db_crashtest2.py index bb8949175..6a28a0ba4 100644 --- a/tools/db_crashtest2.py +++ b/tools/db_crashtest2.py @@ -108,7 +108,7 @@ def main(argv): --max_bytes_for_level_base=10485760 --filter_deletes=%s --memtablerep=prefix_hash - --prefix_size=2 + --prefix_size=7 %s """ % (random.randint(0, 1), threads, diff --git a/tools/db_stress.cc b/tools/db_stress.cc index ca75bacbd..c3b17a0e8 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -338,7 +338,7 @@ static bool ValidatePrefixSize(const char* flagname, int32_t value) { } return true; } -DEFINE_int32(prefix_size, 2, "Control the prefix size for HashSkipListRep"); +DEFINE_int32(prefix_size, 7, "Control the prefix size for HashSkipListRep"); static const bool FLAGS_prefix_size_dummy = google::RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize); @@ -1099,7 +1099,8 @@ class StressTest { // OPERATION prefix scan // keys are 8 bytes long, prefix size is FLAGS_prefix_size. There are // (8 - FLAGS_prefix_size) bytes besides the prefix. So there will - // be 2 ^ ((8 - FLAGS_prefix_size * 8) combinations. + // be 2 ^ ((8 - FLAGS_prefix_size) * 8) possible keys with the same + // prefix if (!FLAGS_test_batches_snapshots) { Slice prefix = Slice(key.data(), FLAGS_prefix_size); read_opts.prefix = &prefix; @@ -1109,7 +1110,8 @@ class StressTest { assert(iter->key().starts_with(prefix)); ++count; } - assert(count <= (1 << ((8 - FLAGS_prefix_size) * 8))); + assert(count <= + (static_cast(1) << ((8 - FLAGS_prefix_size) * 8))); if (iter->status().ok()) { thread->stats.AddPrefixes(1, count); } else {