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
main
Igor Canadi 11 years ago
parent 839c8ecfcd
commit 5ba028c179
  1. 2
      tools/db_crashtest.py
  2. 2
      tools/db_crashtest2.py
  3. 8
      tools/db_stress.cc

@ -94,7 +94,7 @@ def main(argv):
--max_bytes_for_level_base=10485760 --max_bytes_for_level_base=10485760
--filter_deletes=%s --filter_deletes=%s
--memtablerep=prefix_hash --memtablerep=prefix_hash
--prefix_size=2 --prefix_size=7
""" % (ops_per_thread, """ % (ops_per_thread,
threads, threads,
write_buf_size, write_buf_size,

@ -108,7 +108,7 @@ def main(argv):
--max_bytes_for_level_base=10485760 --max_bytes_for_level_base=10485760
--filter_deletes=%s --filter_deletes=%s
--memtablerep=prefix_hash --memtablerep=prefix_hash
--prefix_size=2 --prefix_size=7
%s %s
""" % (random.randint(0, 1), """ % (random.randint(0, 1),
threads, threads,

@ -338,7 +338,7 @@ static bool ValidatePrefixSize(const char* flagname, int32_t value) {
} }
return true; 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 = static const bool FLAGS_prefix_size_dummy =
google::RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize); google::RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize);
@ -1099,7 +1099,8 @@ class StressTest {
// OPERATION prefix scan // OPERATION prefix scan
// keys are 8 bytes long, prefix size is FLAGS_prefix_size. There are // keys are 8 bytes long, prefix size is FLAGS_prefix_size. There are
// (8 - FLAGS_prefix_size) bytes besides the prefix. So there will // (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) { if (!FLAGS_test_batches_snapshots) {
Slice prefix = Slice(key.data(), FLAGS_prefix_size); Slice prefix = Slice(key.data(), FLAGS_prefix_size);
read_opts.prefix = &prefix; read_opts.prefix = &prefix;
@ -1109,7 +1110,8 @@ class StressTest {
assert(iter->key().starts_with(prefix)); assert(iter->key().starts_with(prefix));
++count; ++count;
} }
assert(count <= (1 << ((8 - FLAGS_prefix_size) * 8))); assert(count <=
(static_cast<int64_t>(1) << ((8 - FLAGS_prefix_size) * 8)));
if (iter->status().ok()) { if (iter->status().ok()) {
thread->stats.AddPrefixes(1, count); thread->stats.AddPrefixes(1, count);
} else { } else {

Loading…
Cancel
Save