You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by hu...@apache.org on 2022/06/02 04:35:33 UTC

[incubator-kvrocks] branch unstable updated: Update max_bytes_for_level_base unit to bytes and remove unuseful error checker (#610)

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/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 7a3d964  Update max_bytes_for_level_base unit to bytes and remove unuseful error checker (#610)
7a3d964 is described below

commit 7a3d964c40d974f62079e2406ffeaf53327b34e4
Author: bitstring <i...@eventloop.live>
AuthorDate: Thu Jun 2 12:35:29 2022 +0800

    Update max_bytes_for_level_base unit to bytes and remove unuseful error checker (#610)
---
 kvrocks.conf         |  4 ++--
 src/config.cc        | 19 ++++++++-----------
 src/storage.cc       |  2 +-
 tests/config_test.cc |  2 +-
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/kvrocks.conf b/kvrocks.conf
index e734c91..9d4553c 100644
--- a/kvrocks.conf
+++ b/kvrocks.conf
@@ -635,8 +635,8 @@ rocksdb.level_compaction_dynamic_level_bytes no
 
 # The total file size of level-1 sst.
 #
-# Default: 256 M
-rocksdb.max_bytes_for_level_base 256
+# Default: 268435456 bytes
+rocksdb.max_bytes_for_level_base 268435456 
 
 # Multiplication factor for the total file size of L(n+1) layers.
 # This option is a double type number in RocksDB, but kvrocks is
diff --git a/src/config.cc b/src/config.cc
index 6b7260f..526a798 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -174,7 +174,7 @@ Config::Config() {
       {"rocksdb.blob_garbage_collection_age_cutoff",
        false, new IntField(&RocksDB.blob_garbage_collection_age_cutoff, 25, 0, 100)},
       {"rocksdb.max_bytes_for_level_base",
-        false, new IntField(&RocksDB.max_bytes_for_level_base, 256, 0, INT_MAX)},
+        false, new IntField(&RocksDB.max_bytes_for_level_base, 268435456, 0, INT_MAX)},
       {"rocksdb.max_bytes_for_level_multiplier",
         false, new IntField(&RocksDB.max_bytes_for_level_multiplier, 10, 1, 100)},
       {"rocksdb.level_compaction_dynamic_level_bytes",
@@ -447,13 +447,19 @@ void Config::initFieldCallback() {
         double cutoff = val / 100;
         return srv->storage_->SetColumnFamilyOption(trimRocksDBPrefix(k), std::to_string(cutoff));
       }},
+      {"rocksdb.level_compaction_dynamic_level_bytes", [this](Server* srv, const std::string &k,
+                                                        const std::string& v)->Status {
+        if (!srv) return Status::OK();
+        std::string level_compaction_dynamic_level_bytes = v == "yes" ? "true" : "false";
+        return srv->storage_->SetDBOption(trimRocksDBPrefix(k), level_compaction_dynamic_level_bytes);
+      }},
       {"rocksdb.max_bytes_for_level_base", [this](Server* srv, const std::string &k, const std::string& v)->Status {
         if (!srv) return Status::OK();
         if (!RocksDB.level_compaction_dynamic_level_bytes) {
           return Status(Status::NotOK, errNotSetLevelCompactionDynamicLevelBytes);
         }
         return srv->storage_->SetColumnFamilyOption(trimRocksDBPrefix(k),
-                                                    std::to_string(RocksDB.max_bytes_for_level_base * MiB));
+                                                    std::to_string(RocksDB.max_bytes_for_level_base));
       }},
       {"rocksdb.max_bytes_for_level_multiplier", [this](Server* srv, const std::string &k,
                                                    const std::string& v)->Status {
@@ -463,15 +469,6 @@ void Config::initFieldCallback() {
         }
         return srv->storage_->SetColumnFamilyOption(trimRocksDBPrefix(k), v);
       }},
-      {"rocksdb.level_compaction_dynamic_level_bytes", [this](Server* srv, const std::string &k,
-                                                        const std::string& v)->Status {
-        if (!srv) return Status::OK();
-        if (!RocksDB.level_compaction_dynamic_level_bytes) {
-          return Status(Status::NotOK, errNotSetLevelCompactionDynamicLevelBytes);
-        }
-        std::string level_compaction_dynamic_level_bytes = v == "yes" ? "true" : "false";
-        return srv->storage_->SetDBOption(trimRocksDBPrefix(k), level_compaction_dynamic_level_bytes);
-      }},
       {"rocksdb.max_open_files", set_db_option_cb},
       {"rocksdb.stats_dump_period_sec", set_db_option_cb},
       {"rocksdb.delayed_write_rate", set_db_option_cb},
diff --git a/src/storage.cc b/src/storage.cc
index 9f942db..bac1c81 100644
--- a/src/storage.cc
+++ b/src/storage.cc
@@ -165,7 +165,7 @@ void Storage::InitOptions(rocksdb::Options *options) {
   options->level0_slowdown_writes_trigger = config_->RocksDB.level0_slowdown_writes_trigger;
   options->level0_stop_writes_trigger = config_->RocksDB.level0_stop_writes_trigger;
   options->level0_file_num_compaction_trigger = config_->RocksDB.level0_file_num_compaction_trigger;
-  options->max_bytes_for_level_base = config_->RocksDB.max_bytes_for_level_base * MiB;
+  options->max_bytes_for_level_base = config_->RocksDB.max_bytes_for_level_base;
   options->max_bytes_for_level_multiplier = config_->RocksDB.max_bytes_for_level_multiplier;
   options->level_compaction_dynamic_level_bytes = config_->RocksDB.level_compaction_dynamic_level_bytes;
 }
diff --git a/tests/config_test.cc b/tests/config_test.cc
index fd8afd0..74f31a7 100644
--- a/tests/config_test.cc
+++ b/tests/config_test.cc
@@ -74,7 +74,7 @@ TEST(Config, GetAndSet) {
       {"rocksdb.blob_file_size", "268435456"},
       {"rocksdb.enable_blob_garbage_collection", "yes"},
       {"rocksdb.blob_garbage_collection_age_cutoff", "25"},
-      {"rocksdb.max_bytes_for_level_base", "256"},
+      {"rocksdb.max_bytes_for_level_base", "268435456"},
       {"rocksdb.max_bytes_for_level_multiplier", "10"},
       {"rocksdb.level_compaction_dynamic_level_bytes", "yes"},
   };