From 27b8738ddc6621028918e9d4c57d9aa6a4fbd8ee Mon Sep 17 00:00:00 2001 From: fukua95 Date: Fri, 6 Dec 2024 12:49:44 +0800 Subject: [PATCH] feat(config): add the `partition_filters` option to disable the partitioned filters --- kvrocks.conf | 5 +++++ src/config/config.cc | 5 +++-- src/config/config.h | 1 + src/storage/storage.cc | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kvrocks.conf b/kvrocks.conf index 84a08d25db0..16a980e5d51 100644 --- a/kvrocks.conf +++ b/kvrocks.conf @@ -1016,6 +1016,11 @@ rocksdb.write_options.memtable_insert_hint_per_batch no # Default: yes rocksdb.rate_limiter_auto_tuned yes +# If enabled, rocksdb will use partitioned full filters for each SST file. +# +# Default: yes +rocksdb.partition_filters 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 diff --git a/src/config/config.cc b/src/config/config.cc index b670c38763e..ce97f4d323d 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -131,8 +131,8 @@ Status SetRocksdbCompression(Server *srv, const rocksdb::CompressionType compres for (size_t i = compression_start_level; i < KVROCKS_MAX_LSM_LEVEL; i++) { compression_per_level_builder.emplace_back(compression_option); } - const std::string compression_per_level = util::StringJoin( - compression_per_level_builder, [](const auto &s) -> decltype(auto) { return s; }, ":"); + const std::string compression_per_level = + util::StringJoin(compression_per_level_builder, [](const auto &s) -> decltype(auto) { return s; }, ":"); return srv->storage->SetOptionForAllColumnFamilies("compression_per_level", compression_per_level); }; @@ -298,6 +298,7 @@ Config::Config() { {"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.partition_filters", true, new YesNoField(&rocks_db.partition_filters, 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 1e095bd1a8c..9fa5d4168fc 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -220,6 +220,7 @@ struct Config { int max_background_jobs; bool rate_limiter_auto_tuned; bool avoid_unnecessary_blocking_io = true; + bool partition_filters; struct WriteOptions { bool sync; diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 39739a54868..8e3140c4cd9 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -136,7 +136,7 @@ rocksdb::BlockBasedTableOptions Storage::InitTableOptions() { table_options.format_version = 5; table_options.index_type = rocksdb::BlockBasedTableOptions::IndexType::kTwoLevelIndexSearch; table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, false)); - table_options.partition_filters = true; + table_options.partition_filters = config_->rocks_db.partition_filters; table_options.optimize_filters_for_memory = true; table_options.metadata_block_size = 4096; table_options.data_block_index_type = rocksdb::BlockBasedTableOptions::DataBlockIndexType::kDataBlockBinaryAndHash;