empiredan commented on a change in pull request #646:
URL: https://github.com/apache/incubator-pegasus/pull/646#discussion_r530149511



##########
File path: src/server/pegasus_server_impl_init.cpp
##########
@@ -299,6 +300,130 @@ 
pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
         _db_opts.rate_limiter = _s_rate_limiter;
     }
 
+    bool enable_write_buffer_manager = dsn_config_get_value_bool(
+                "pegasus.server",
+                "rocksdb_enable_write_buffer_manager",
+                false,
+                "enable write buffer manager to limit total memory "
+                "used by memtables and block caches across multiple replicas");
+    ddebug("rocksdb_enable_write_buffer_manager = %d", 
enable_write_buffer_manager);
+    if (enable_write_buffer_manager) {
+        // If write buffer manager is enabled, all replicas(one DB instance 
for each
+        // replica) on this server will share the same write buffer manager 
object,
+        // thus the same block cache object. It's convenient to control the 
total memory
+        // of memtables and bloack caches used by this server
+        static std::once_flag flag;
+        std::call_once(flag, [&]() {
+            int64_t total_size_across_write_buffer = 
dsn_config_get_value_int64(
+                    "pegasus.server",
+                    "rocksdb_total_size_across_write_buffer",
+                    0,
+                    "total size limit used by memtables across multiple 
replicas");
+            ddebug("rocksdb_total_size_across_write_buffer = %" PRId64, 
total_size_across_write_buffer);
+            if (total_size_across_write_buffer < 0) {
+                total_size_across_write_buffer = 0;
+            }
+            _s_write_buffer_manager = 
std::make_shared<rocksdb::WriteBufferManager>(
+                    static_cast<size_t>(total_size_across_write_buffer), 
tbl_opts.block_cache);
+        });
+        _db_opts.write_buffer_manager = _s_write_buffer_manager;
+    }
+
+    int64_t max_open_files = dsn_config_get_value_int64(
+            "pegasus.server",
+            "rocksdb_max_open_files",
+            -1,
+            "number of open files that can be used by a replica(namely a DB 
instance)");
+    _db_opts.max_open_files = static_cast<int>(max_open_files);
+    ddebug("rocksdb_max_open_files = %d", _db_opts.max_open_files);
+
+    std::string index_type = dsn_config_get_value_string(
+            "pegasus.server",
+            "rocksdb_index_type",
+            "kBinarySearch",
+            "The index type that will be used for this table.");
+    const std::unordered_map<std::string, 
rocksdb::BlockBasedTableOptions::IndexType>
+    index_type_string_map = {
+        {"kBinarySearch", 
rocksdb::BlockBasedTableOptions::IndexType::kBinarySearch},
+        {"kHashSearch", 
rocksdb::BlockBasedTableOptions::IndexType::kHashSearch},
+        {"kTwoLevelIndexSearch",
+         rocksdb::BlockBasedTableOptions::IndexType::kTwoLevelIndexSearch},
+        {"kBinarySearchWithFirstKey",
+         rocksdb::BlockBasedTableOptions::IndexType::kBinarySearchWithFirstKey}
+    };
+    auto index_type_item = index_type_string_map.find(index_type);
+    dassert(index_type_item != index_type_string_map.end(),
+            "[pegasus.server]rocksdb_index_type shold be one among 
kBinarySearch, "
+            "kHashSearch, kTwoLevelIndexSearch or kBinarySearchWithFirstKey.");
+    tbl_opts.index_type = index_type_item->second;
+    ddebug("rocksdb_index_type = %s", index_type.c_str());

Review comment:
       Actually, since I'd decided to cache index and filter blocks, I just 
took this opportunity to involve partitioned indexes in. However we've been 
developing pegasus based on v1.12.3, whose rocksdb's version is 5.9.2 and not 
high enough to support index and filter blocks cached well. After several 
related core-dumps had happened we had to disable all the options about the 
cache and partitioned indexes. Until I saw the version of rocksdb used by 
latest pegasus had reached 6.6.4, I thought those options could be enabled 
again albeit disabled still by default. Unfortunately we've not done any 
performance test since.  I think these options should be enabled by users if 
necessary




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to