diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 90fde4a30d45f7fa01d5a9c51a2fe3f4243762d8..449d854278049ea7cda80334fd2b1b967662a1be 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -24,6 +24,7 @@ default_params = { "disable_data_sync": 0, "disable_wal": 0, "filter_deletes": lambda: random.randint(0, 1), + "allow_concurrent_memtable_write": lambda: random.randint(0, 1), "iterpercent": 10, "max_background_compactions": 20, "max_bytes_for_level_base": 10485760, @@ -85,6 +86,7 @@ simple_default_params = { "disable_data_sync": 0, "disable_wal": 0, "filter_deletes": lambda: random.randint(0, 1), + "allow_concurrent_memtable_write": lambda: random.randint(0, 1), "iterpercent": 10, "max_background_compactions": 1, "max_bytes_for_level_base": 67108864, @@ -126,6 +128,15 @@ whitebox_simple_default_params = { } +def finalize_and_sanitize(src_params): + dest_params = dict([(k, v() if callable(v) else v) + for (k, v) in src_params.items()]) + # --allow_concurrent_memtable_write with --filter_deletes is not supported. + if dest_params.get("allow_concurrent_memtable_write", 1) == 1: + dest_params["filter_deletes"] = 0 + return dest_params + + def gen_cmd_params(args): params = {} @@ -151,8 +162,8 @@ def gen_cmd_params(args): def gen_cmd(params): cmd = './db_stress ' + ' '.join( - '--{0}={1}'.format(k, v() if callable(v) else v) - for k, v in params.items() + '--{0}={1}'.format(k, v) + for k, v in finalize_and_sanitize(params).items() if k not in set(['test_type', 'simple', 'duration', 'interval']) and v is not None) return cmd diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 102803862c621e2c93bd826455296ad7b8559dc0..10193a182c17fcd876fe0f0854ac3701f55e87e9 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -230,6 +230,13 @@ DEFINE_int64(cache_size, 2LL * KB * KB * KB, DEFINE_uint64(subcompactions, 1, "Maximum number of subcompactions to divide L0-L1 compactions " "into."); + +DEFINE_bool(allow_concurrent_memtable_write, true, + "Allow multi-writers to update mem tables in parallel."); + +DEFINE_bool(enable_write_thread_adaptive_yield, true, + "Use a yielding spin loop for brief writer thread waits."); + static const bool FLAGS_subcompactions_dummy __attribute__((unused)) = RegisterFlagValidator(&FLAGS_subcompactions, &ValidateUint32Range); @@ -1997,6 +2004,10 @@ class StressTest { options_.filter_deletes = FLAGS_filter_deletes; options_.inplace_update_support = FLAGS_in_place_update; options_.max_subcompactions = static_cast(FLAGS_subcompactions); + options_.allow_concurrent_memtable_write = + FLAGS_allow_concurrent_memtable_write; + options_.enable_write_thread_adaptive_yield = + FLAGS_enable_write_thread_adaptive_yield; if ((FLAGS_prefix_size == 0) == (FLAGS_rep_factory == kHashSkipList)) { fprintf(stderr, "prefix_size should be non-zero iff memtablerep == prefix_hash\n");