From 836534debdacd99fa0fc428802ee1cbff9ceb44f Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Mon, 17 Jun 2013 13:51:12 -0700 Subject: [PATCH] Enhance dbstress to allow specifying compaction trigger for L0. Summary: Rocksdb allos specifying the number of files in L0 that triggers compactions. Expose this api as a command line parameter for running db_stress. Test Plan: Run test Reviewers: sheki, emayanke Reviewed By: emayanke CC: leveldb Differential Revision: https://reviews.facebook.net/D11343 --- tools/db_stress.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 571d690eb..a5cb5b35e 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -177,6 +177,9 @@ static uint32_t FLAGS_log2_keys_per_lock = 2; // implies 2^2 keys per lock // Percentage of times we want to purge redundant keys in memory before flushing static uint32_t FLAGS_purge_redundant_percent = 50; +// Level0 compaction start trigger +static int FLAGS_level0_file_num_compaction_trigger = 0; + namespace leveldb { class StressTest; @@ -940,6 +943,8 @@ class StressTest { options.level0_stop_writes_trigger = FLAGS_level0_stop_writes_trigger; options.level0_slowdown_writes_trigger = FLAGS_level0_slowdown_writes_trigger; + options.level0_file_num_compaction_trigger = + FLAGS_level0_file_num_compaction_trigger; options.compression = FLAGS_compression_type; options.create_if_missing = true; options.disable_seek_compaction = FLAGS_disable_seek_compaction; @@ -1004,6 +1009,12 @@ int main(int argc, char** argv) { FLAGS_open_files = leveldb::Options().max_open_files; FLAGS_max_background_compactions = leveldb::Options().max_background_compactions; + FLAGS_level0_file_num_compaction_trigger = + leveldb::Options().level0_file_num_compaction_trigger; + FLAGS_level0_slowdown_writes_trigger = + leveldb::Options().level0_slowdown_writes_trigger; + FLAGS_level0_stop_writes_trigger = + leveldb::Options().level0_stop_writes_trigger; // Compression test code above refers to FLAGS_block_size FLAGS_block_size = leveldb::Options().block_size; std::string default_db_path; @@ -1111,6 +1122,9 @@ int main(int argc, char** argv) { } else if (sscanf(argv[i],"--level0_slowdown_writes_trigger=%d%c", &n, &junk) == 1) { FLAGS_level0_slowdown_writes_trigger = n; + } else if (sscanf(argv[i],"--level0_file_num_compaction_trigger=%d%c", + &n, &junk) == 1) { + FLAGS_level0_file_num_compaction_trigger = n; } else if (strncmp(argv[i], "--compression_type=", 19) == 0) { const char* ctype = argv[i] + 19; if (!strcasecmp(ctype, "none")) -- GitLab