Skip to content

Commit

Permalink
Merge pull request #11599 from tanghaodong25/wip-2q-cache
Browse files Browse the repository at this point in the history
os/bluestore: make 2q cache kin/kout size tunable

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Oct 21, 2016
2 parents 6fb2860 + f7dd190 commit e58bd89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Expand Up @@ -996,6 +996,8 @@ OPTION(bluestore_extent_map_shard_min_size, OPT_U32, 150)
OPTION(bluestore_extent_map_shard_target_size_slop, OPT_DOUBLE, .2)
OPTION(bluestore_extent_map_inline_shard_prealloc_size, OPT_U32, 256)
OPTION(bluestore_cache_type, OPT_STR, "2q") // lru, 2q
OPTION(bluestore_2q_cache_kin_ratio, OPT_DOUBLE, .5) // kin page slot size / max page slot size
OPTION(bluestore_2q_cache_kout_ratio, OPT_DOUBLE, .5) // number of kout page slot / total number of page slot
OPTION(bluestore_onode_cache_size, OPT_U32, 4*1024)
OPTION(bluestore_buffer_cache_size, OPT_U32, 512*1024*1024)
OPTION(bluestore_kvbackend, OPT_STR, "rocksdb")
Expand Down
7 changes: 4 additions & 3 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -710,8 +710,8 @@ void BlueStore::TwoQCache::trim(uint64_t onode_max, uint64_t buffer_max)

// buffers
if (buffer_bytes > buffer_max) {
uint64_t kin = buffer_max / 2;
uint64_t khot = kin;
uint64_t kin = buffer_max * g_conf->bluestore_2q_cache_kin_ratio;
uint64_t khot = buffer_max - kin;

// pre-calculate kout based on average buffer size too,
// which is typical(the warm_in and hot lists may change later)
Expand All @@ -720,7 +720,8 @@ void BlueStore::TwoQCache::trim(uint64_t onode_max, uint64_t buffer_max)
if (buffer_num) {
uint64_t buffer_avg_size = buffer_bytes / buffer_num;
assert(buffer_avg_size);
kout = buffer_max / buffer_avg_size;
uint64_t caculated_buffer_num = buffer_max / buffer_avg_size;
kout = caculated_buffer_num * g_conf->bluestore_2q_cache_kout_ratio;
}

if (buffer_list_bytes[BUFFER_HOT] < khot) {
Expand Down

0 comments on commit e58bd89

Please sign in to comment.