This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 2b9faf78 Enable rocksdb read option `avoid_unnecessary_blocking_io` to
avoid unexpected long latency (#1903)
2b9faf78 is described below
commit 2b9faf782fbfff4d6dab091540101c678546b146
Author: Ted Mostly <[email protected]>
AuthorDate: Wed Nov 22 23:54:57 2023 +0800
Enable rocksdb read option `avoid_unnecessary_blocking_io` to avoid
unexpected long latency (#1903)
Co-authored-by: hulk <[email protected]>
---
kvrocks.conf | 7 +++++++
src/config/config.cc | 1 +
src/config/config.h | 1 +
src/storage/storage.cc | 3 +++
4 files changed, 12 insertions(+)
diff --git a/kvrocks.conf b/kvrocks.conf
index fa36d96a..e5460187 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 f9cf8cf6..c71103b7 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 d3dc1442..244f1469 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 9c5d03af..77d0ab27 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;
}