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

feat: Add a feature which support partitioned index filter #2601

Merged
merged 2 commits into from
Apr 19, 2024
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
6 changes: 6 additions & 0 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ thread-migrate-keys-num : 64
# The slot number of pika when used with codis.
default-slot-num : 1024

# enable-partitioned-index-filters [yes | no]
# When `cache-index-and-filter-blocks` is enabled, `pin_l0_filter_and_index_blocks_in_cache`
# and `cache-index-and-filter-blocks` is suggested to be enabled
# https://github.com/facebook/rocksdb/wiki/Partitioned-Index-Filters
# enable-partitioned-index-filters: default no

# whether or not index and filter blocks is stored in block cache
# cache-index-and-filter-blocks: no

Expand Down
5 changes: 5 additions & 0 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ class PikaConf : public pstd::BaseConf {
std::shared_lock l(rwlock_);
return share_block_cache_;
}
bool enable_partitioned_index_filters() {
std::shared_lock l(rwlock_);
return enable_partitioned_index_filters_;
}
bool cache_index_and_filter_blocks() {
std::shared_lock l(rwlock_);
return cache_index_and_filter_blocks_;
Expand Down Expand Up @@ -851,6 +855,7 @@ class PikaConf : public pstd::BaseConf {
int64_t block_cache_ = 0;
int64_t num_shard_bits_ = 0;
bool share_block_cache_ = false;
bool enable_partitioned_index_filters_ = false;
bool cache_index_and_filter_blocks_ = false;
bool pin_l0_filter_and_index_blocks_in_cache_ = false;
bool optimize_filters_for_hits_ = false;
Expand Down
6 changes: 6 additions & 0 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,12 @@ void ConfigCmd::ConfigGet(std::string& ret) {
EncodeString(&config_body, g_pika_conf->share_block_cache() ? "yes" : "no");
}

if (pstd::stringmatch(pattern.data(), "enable-partitioned-index-filters", 1) != 0) {
elements += 2;
EncodeString(&config_body, "enable-partitioned-index-filters");
EncodeString(&config_body, g_pika_conf->enable_partitioned_index_filters() ? "yes" : "no");
}

if (pstd::stringmatch(pattern.data(), "cache-index-and-filter-blocks", 1) != 0) {
elements += 2;
EncodeString(&config_body, "cache-index-and-filter-blocks");
Expand Down
4 changes: 4 additions & 0 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ int PikaConf::Load() {
GetConfStr("share-block-cache", &sbc);
share_block_cache_ = sbc == "yes";

std::string epif;
GetConfStr("enable-partitioned-index-filters", &epif);
enable_partitioned_index_filters_ = epif == "yes";

std::string ciafb;
GetConfStr("cache-index-and-filter-blocks", &ciafb);
cache_index_and_filter_blocks_ = ciafb == "yes";
Expand Down
11 changes: 11 additions & 0 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,17 @@ void PikaServer::InitStorageOptions() {
// for column-family options
storage_options_.options.ttl = g_pika_conf->rocksdb_ttl_second();
storage_options_.options.periodic_compaction_seconds = g_pika_conf->rocksdb_periodic_compaction_second();

// For Partitioned Index Filters
if (g_pika_conf->enable_partitioned_index_filters()) {
storage_options_.table_options.index_type = rocksdb::BlockBasedTableOptions::IndexType::kTwoLevelIndexSearch;
storage_options_.table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10, false));
storage_options_.table_options.partition_filters = true;
storage_options_.table_options.metadata_block_size = 4096;
storage_options_.table_options.cache_index_and_filter_blocks_with_high_priority = true;
storage_options_.table_options.pin_top_level_index_and_filter = true;
storage_options_.table_options.optimize_filters_for_memory = true;
}
}

storage::Status PikaServer::RewriteStorageOptions(const storage::OptionType& option_type,
Expand Down
Loading