From 2ead4023ff294b7d68b674e4fd50902f5e10ac1e Mon Sep 17 00:00:00 2001 From: abbycin Date: Sun, 24 Aug 2025 21:44:02 +0800 Subject: [PATCH] disable gc during test --- .gitignore | 1 + rocksdb/main.cpp | 9 ++++++++- src/main.rs | 12 +++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1861325..a9e4dbf 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ *.png *.csv pyvenv.cfg +Cargo.lock diff --git a/rocksdb/main.cpp b/rocksdb/main.cpp index 0918f4d..a23f4dd 100644 --- a/rocksdb/main.cpp +++ b/rocksdb/main.cpp @@ -80,8 +80,14 @@ int main(int argc, char *argv[]) { options.create_if_missing = true; options.allow_concurrent_memtable_write = true; options.enable_pipelined_write = true; + // the following three options makes it not trigger GC in test + options.level0_file_num_compaction_trigger = 1000; + options.write_buffer_size = 1 << 30; + options.max_write_buffer_number = 5; + auto ropt = rocksdb::ReadOptions(); auto wopt = rocksdb::WriteOptions(); + // wopt.disableWAL = true; std::vector wg; std::vector> keys{}; std::atomic total_op{0}; @@ -175,7 +181,8 @@ int main(int argc, char *argv[]) { return args.mode == "insert" ? 100 : 0; }(); double ops = static_cast(total_op.load(std::memory_order_relaxed)) / b.elapse_sec(); - std::println("{},{},{},{},{},{:.2f}", args.mode, args.threads, args.key_size, args.value_size, ratio, ops); + std::println("{},{},{},{},{},{:.2f},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, ops, + b.elapse_ms()); delete db; std::filesystem::remove_all(args.path); } diff --git a/src/main.rs b/src/main.rs index 338bbec..8e6701e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,7 +66,7 @@ fn main() { let mut opt = Options::new(path); opt.sync_on_write = false; opt.tmp_store = true; - opt.consolidate_threshold = 512; + opt.gc_timeout = 1000 * 60; // make sure GC will not work // opt.cache_capacity = 3 << 30; // this is very important for large key-value store let db = Mace::new(opt.validate().unwrap()).unwrap(); @@ -184,7 +184,13 @@ fn main() { }; // eprintln!("mode,threads,key_size,value_size,insert_ratio,ops"); eprintln!( - "{},{},{},{},{},{:.2}", - args.mode, args.threads, args.key_size, args.value_size, ratio, ops + "{},{},{},{},{},{:.2},{}", + args.mode, + args.threads, + args.key_size, + args.value_size, + ratio, + ops, + duration.as_millis() ); }