Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Rocksdb read 'cache keys shard bits' from the configuration file #1189

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ max-bytes-for-level-multiplier : 10
# block-size: 4096
# block LRU cache, default 8M, 0 to disable
# block-cache: 8388608
# num-shard-bits default -1, the number of bits from cache keys to be use as shard id.
# The cache will be sharded into 2^num_shard_bits shards.
# /~https://github.com/EighteenZi/rocksdb_wiki/blob/master/Block-Cache.md#lru-cache
# num-shard-bits: -1
# whether the block cache is shared among the RocksDB instances, default is per CF
# share-block-cache: no
# whether or not index and filter blocks is stored in block cache
Expand Down
2 changes: 2 additions & 0 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class PikaConf : public slash::BaseConf {
int max_bytes_for_level_multiplier() { RWLock l(&rwlock_, false); return max_bytes_for_level_multiplier_; }
int64_t block_size() { RWLock l(&rwlock_, false); return block_size_; }
int64_t block_cache() { RWLock l(&rwlock_, false); return block_cache_; }
int64_t num_shard_bits() { RWLock l(&rwlock_, false); return num_shard_bits_; }
bool share_block_cache() { RWLock l(&rwlock_, false); return share_block_cache_; }
bool cache_index_and_filter_blocks() { RWLock l(&rwlock_, false); return cache_index_and_filter_blocks_; }
bool pin_l0_filter_and_index_blocks_in_cache() { RWLock l(&rwlock_, false); return pin_l0_filter_and_index_blocks_in_cache_; }
Expand Down Expand Up @@ -342,6 +343,7 @@ class PikaConf : public slash::BaseConf {
int max_bytes_for_level_multiplier_;
int64_t block_size_;
int64_t block_cache_;
int64_t num_shard_bits_;
bool share_block_cache_;
bool cache_index_and_filter_blocks_;
bool pin_l0_filter_and_index_blocks_in_cache_;
Expand Down
3 changes: 3 additions & 0 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ int PikaConf::Load()
block_cache_ = 8 * 1024 * 1024;
}

num_shard_bits_ = -1;
GetConfInt64("num-shard-bits", &num_shard_bits_);

std::string sbc;
GetConfStr("share-block-cache", &sbc);
share_block_cache_ = (sbc == "yes") ? true : false;
Expand Down
2 changes: 1 addition & 1 deletion src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ void PikaServer::InitBlackwidowOptions() {
bw_options_.table_options.no_block_cache = true;
} else if (bw_options_.share_block_cache) {
bw_options_.table_options.block_cache =
rocksdb::NewLRUCache(bw_options_.block_cache_size);
rocksdb::NewLRUCache(bw_options_.block_cache_size, g_pika_conf->num_shard_bits());
}

// For Blackwidow small compaction
Expand Down