diff --git a/kvrocks.conf b/kvrocks.conf index fa36d96a2a6..e5460187f72 100644 --- a/kvrocks.conf +++ b/kvrocks.conf @@ -863,5 +863,12 @@ rocksdb.write_options.memtable_insert_hint_per_batch no # Default: yes rocksdb.rate_limiter_auto_tuned yes +# Enable this option will schedule the deletion of obsolete files in a background thread +# on iterator destruction. It can reduce the latency if there are many files to be removed. +# see https://github.com/facebook/rocksdb/wiki/IO#avoid-blocking-io +# +# Default: yes +# rocksdb.avoid_unnecessary_blocking_io yes + ################################ NAMESPACE ##################################### # namespace.test change.me diff --git a/src/config/config.cc b/src/config/config.cc index f9cf8cf6812..c71103b73d8 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -216,6 +216,7 @@ Config::Config() { new YesNoField(&rocks_db.level_compaction_dynamic_level_bytes, false)}, {"rocksdb.max_background_jobs", false, new IntField(&rocks_db.max_background_jobs, 4, 0, 32)}, {"rocksdb.rate_limiter_auto_tuned", true, new YesNoField(&rocks_db.rate_limiter_auto_tuned, true)}, + {"rocksdb.avoid_unnecessary_blocking_io", true, new YesNoField(&rocks_db.avoid_unnecessary_blocking_io, true)}, /* rocksdb write options */ {"rocksdb.write_options.sync", true, new YesNoField(&rocks_db.write_options.sync, false)}, diff --git a/src/config/config.h b/src/config/config.h index d3dc1442931..244f1469b19 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -201,6 +201,7 @@ struct Config { bool level_compaction_dynamic_level_bytes; int max_background_jobs; bool rate_limiter_auto_tuned; + bool avoid_unnecessary_blocking_io = true; struct WriteOptions { bool sync; diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 9c5d03af312..77d0ab27801 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -186,6 +186,9 @@ rocksdb::Options Storage::InitRocksDBOptions() { options.level_compaction_dynamic_level_bytes = config_->rocks_db.level_compaction_dynamic_level_bytes; options.max_background_jobs = config_->rocks_db.max_background_jobs; + // avoid blocking io on iteration + // see https://github.com/facebook/rocksdb/wiki/IO#avoid-blocking-io + options.avoid_unnecessary_blocking_io = config_->rocks_db.avoid_unnecessary_blocking_io; return options; }