From 3b6653b1f8ca82771e41d61be2d472399676b455 Mon Sep 17 00:00:00 2001 From: amayank Date: Wed, 6 Mar 2013 12:54:55 -0800 Subject: [PATCH] Make db_stress Not purge redundant keys on some opens Summary: In light of the new option introduced by commit 806e26435037f5e2eb3b8c2d1e5f278a86fdb2ba where the database has an option to compact before flushing to disk, we want the stress test to test both sides of the option. Have made it to 'deterministically' and configurably change that option for reopens. Test Plan: make db_stress; ./db_stress with some differnet options Reviewers: dhruba, vamsi Reviewed By: dhruba CC: leveldb, sheki Differential Revision: https://reviews.facebook.net/D9165 --- tools/db_stress.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index aeaafb42e..2725d4ca3 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -158,6 +158,9 @@ static uint32_t FLAGS_ops_per_thread = 600000; // Log2 of number of keys per lock 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; + extern bool useOsBuffer; extern bool useFsReadAhead; extern bool useMmapRead; @@ -843,6 +846,8 @@ class StressTest { fprintf(stdout, "Num times DB reopens: %d\n", FLAGS_reopen); fprintf(stdout, "Batches/snapshots : %d\n", FLAGS_test_batches_snapshots); + fprintf(stdout, "Purge redundant %% : %d\n", + FLAGS_purge_redundant_percent); fprintf(stdout, "Num keys per lock : %d\n", 1 << FLAGS_log2_keys_per_lock); @@ -894,6 +899,10 @@ class StressTest { options.delete_obsolete_files_period_micros = FLAGS_delete_obsolete_files_period_micros; options.max_manifest_file_size = 1024; + static Random purge_percent(1000); // no benefit from non-determinism here + if (purge_percent.Uniform(100) < FLAGS_purge_redundant_percent - 1) { + options.purge_redundant_kvs_while_flush = false; + } Status s = DB::Open(options, FLAGS_db, &db_); if (!s.ok()) { fprintf(stderr, "open error: %s\n", s.ToString().c_str()); @@ -1066,6 +1075,9 @@ int main(int argc, char** argv) { } else if (sscanf(argv[i], "--delete_obsolete_files_period_micros=%ld%c", &l, &junk) == 1) { FLAGS_delete_obsolete_files_period_micros = n; + } else if (sscanf(argv[i], "--purge_redundant_percent=%d%c", &n, &junk) == 1 + && (n >= 0 && n <= 100)) { + FLAGS_purge_redundant_percent = n; } else { fprintf(stderr, "Invalid flag '%s'\n", argv[i]); exit(1);