This is an automated email from the ASF dual-hosted git repository.
twice 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 065d4cfbf feat(config): allow to configure the
rocksdb.min_write_buffer_number_to_merge (#3016)
065d4cfbf is described below
commit 065d4cfbfea7034d80df770c0c525e4e4abbb702
Author: Nathan <[email protected]>
AuthorDate: Thu Jun 5 02:06:30 2025 -0400
feat(config): allow to configure the
rocksdb.min_write_buffer_number_to_merge (#3016)
Co-authored-by: hulk <[email protected]>
Co-authored-by: Twice <[email protected]>
Co-authored-by: Twice <[email protected]>
---
kvrocks.conf | 7 +++++++
src/config/config.cc | 3 +++
src/config/config.h | 1 +
src/storage/storage.cc | 2 +-
tests/cppunit/config_test.cc | 1 +
5 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/kvrocks.conf b/kvrocks.conf
index 45ba1791d..a8a0de53d 100644
--- a/kvrocks.conf
+++ b/kvrocks.conf
@@ -728,6 +728,13 @@ rocksdb.target_file_size_base 128
# allowed.
rocksdb.max_write_buffer_number 4
+# The minimum number of write buffers that will be merged together
+# during compaction.
+#
+# Default: 1
+rocksdb.min_write_buffer_number_to_merge 1
+
+
# Maximum number of concurrent background jobs (compactions and flushes).
# For backwards compatibility we will set `max_background_jobs =
# max_background_compactions + max_background_flushes` in the case where user
diff --git a/src/config/config.cc b/src/config/config.cc
index 7a615b88b..52f5266b0 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -252,6 +252,8 @@ Config::Config() {
{"rocksdb.max_open_files", false, new IntField(&rocks_db.max_open_files,
8096, -1, INT_MAX)},
{"rocksdb.write_buffer_size", false, new
IntField(&rocks_db.write_buffer_size, 64, 0, 4096)},
{"rocksdb.max_write_buffer_number", false, new
IntField(&rocks_db.max_write_buffer_number, 4, 0, 256)},
+ {"rocksdb.min_write_buffer_number_to_merge", false,
+ new IntField(&rocks_db.min_write_buffer_number_to_merge, 1, 1, 256)},
{"rocksdb.target_file_size_base", false, new
IntField(&rocks_db.target_file_size_base, 128, 1, 1024)},
{"rocksdb.max_background_compactions", false, new
IntField(&rocks_db.max_background_compactions, 2, -1, 32)},
{"rocksdb.max_background_flushes", true, new
IntField(&rocks_db.max_background_flushes, 2, -1, 32)},
@@ -728,6 +730,7 @@ void Config::initFieldCallback() {
{"rocksdb.max_compaction_bytes", set_cf_option_cb},
{"rocksdb.max_write_buffer_number", set_cf_option_cb},
+ {"rocksdb.min_write_buffer_number_to_merge", set_cf_option_cb},
{"rocksdb.level0_slowdown_writes_trigger", set_cf_option_cb},
{"rocksdb.level0_stop_writes_trigger", set_cf_option_cb},
{"rocksdb.level0_file_num_compaction_trigger", set_cf_option_cb},
diff --git a/src/config/config.h b/src/config/config.h
index 4646f709c..71b2dab85 100644
--- a/src/config/config.h
+++ b/src/config/config.h
@@ -203,6 +203,7 @@ struct Config {
int max_open_files;
int write_buffer_size;
int max_write_buffer_number;
+ int min_write_buffer_number_to_merge;
int max_background_compactions;
int max_background_flushes;
int max_subcompactions;
diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index 4f4e55d2e..124fbfc78 100644
--- a/src/storage/storage.cc
+++ b/src/storage/storage.cc
@@ -169,7 +169,7 @@ rocksdb::Options Storage::InitRocksDBOptions() {
options.max_background_flushes = config_->rocks_db.max_background_flushes;
options.max_background_compactions =
config_->rocks_db.max_background_compactions;
options.max_write_buffer_number = config_->rocks_db.max_write_buffer_number;
- options.min_write_buffer_number_to_merge = 2;
+ options.min_write_buffer_number_to_merge =
config_->rocks_db.min_write_buffer_number_to_merge;
options.write_buffer_size = config_->rocks_db.write_buffer_size * MiB;
options.num_levels = KVROCKS_MAX_LSM_LEVEL;
options.compression_opts.level = config_->rocks_db.compression_level;
diff --git a/tests/cppunit/config_test.cc b/tests/cppunit/config_test.cc
index 2a6ac1b56..301c373ab 100644
--- a/tests/cppunit/config_test.cc
+++ b/tests/cppunit/config_test.cc
@@ -65,6 +65,7 @@ TEST(Config, GetAndSet) {
{"rocksdb.max_open_files", "1234"},
{"rocksdb.write_buffer_size", "1234"},
{"rocksdb.max_write_buffer_number", "1"},
+ {"rocksdb.min_write_buffer_number_to_merge", "1"},
{"rocksdb.target_file_size_base", "100"},
{"rocksdb.max_background_compactions", "-1"},
{"rocksdb.max_subcompactions", "3"},