diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index 2a1f340a2f..fb9b5f9f04 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -133,7 +133,7 @@ DECLARE_uint64(compaction_ttl); DECLARE_bool(allow_concurrent_memtable_write); DECLARE_bool(enable_write_thread_adaptive_yield); DECLARE_int32(reopen); -DECLARE_int32(bloom_bits); +DECLARE_double(bloom_bits); DECLARE_bool(use_block_based_filter); DECLARE_bool(partition_filters); DECLARE_int32(index_type); @@ -342,6 +342,17 @@ extern inline std::string StringToHex(const std::string& str) { return result; } +// Unified output format for double parameters +extern inline std::string FormatDoubleParam(double param) { + return std::to_string(param); +} + +// Make sure that double parameter is a value we can reproduce by +// re-inputting the value printed. +extern inline void SanitizeDoubleParam(double* param) { + *param = std::atof(FormatDoubleParam(*param).c_str()); +} + extern void PoolSizeChangeThread(void* v); extern void PrintKeyValue(int cf, uint64_t key, const char* value, size_t sz); diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index fbbdc04e17..e1f01b14d4 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -275,9 +275,9 @@ DEFINE_int32(reopen, 10, "Number of times database reopens"); static const bool FLAGS_reopen_dummy __attribute__((__unused__)) = RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive); -DEFINE_int32(bloom_bits, 10, - "Bloom filter bits per key. " - "Negative means use default settings."); +DEFINE_double(bloom_bits, 10, + "Bloom filter bits per key. " + "Negative means use default settings."); DEFINE_bool(use_block_based_filter, false, "use block based filter" diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 301d5b8e4e..c1d254438f 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -1310,6 +1310,8 @@ void StressTest::PrintEnv() const { fprintf(stdout, "Compression : %s\n", compression.c_str()); std::string checksum = ChecksumTypeToString(FLAGS_checksum_type_e); fprintf(stdout, "Checksum type : %s\n", checksum.c_str()); + fprintf(stdout, "Bloom bits / key : %s\n", + FormatDoubleParam(FLAGS_bloom_bits).c_str()); fprintf(stdout, "Max subcompactions : %" PRIu64 "\n", FLAGS_subcompactions); fprintf(stdout, "Use MultiGet : %s\n", diff --git a/db_stress_tool/db_stress_tool.cc b/db_stress_tool/db_stress_tool.cc index 4ce42d0dd6..5fb6dee006 100644 --- a/db_stress_tool/db_stress_tool.cc +++ b/db_stress_tool/db_stress_tool.cc @@ -34,6 +34,10 @@ int db_stress_tool(int argc, char** argv) { " [OPTIONS]..."); ParseCommandLineFlags(&argc, &argv, true); + SanitizeDoubleParam(&FLAGS_bloom_bits); + SanitizeDoubleParam(&FLAGS_memtable_prefix_bloom_size_ratio); + SanitizeDoubleParam(&FLAGS_max_bytes_for_level_multiplier); + if (FLAGS_statistics) { dbstats = rocksdb::CreateDBStatistics(); if (FLAGS_enable_secondary) { diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 1ff7f40c81..9f9c83a6b3 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -25,6 +25,8 @@ expected_values_file = tempfile.NamedTemporaryFile() default_params = { "acquire_snapshot_one_in": 10000, "block_size": 16384, + "bloom_bits": lambda: random.choice([random.randint(0,19), + random.lognormvariate(2.3, 1.3)]), "cache_index_and_filter_blocks": lambda: random.randint(0, 1), "cache_size": 1048576, "checkpoint_one_in": 1000000,