diff options
author | Mark Nelson <mnelson@redhat.com> | 2018-12-12 20:41:11 +0100 |
---|---|---|
committer | Mark Nelson <mnelson@redhat.com> | 2019-01-04 19:45:20 +0100 |
commit | 875a9dfed832ca77322defd822a4526b01c71d94 (patch) | |
tree | 7ae40f149a64eaad66c9785c62a7ee252989cce1 /src/kv | |
parent | Merge PR #24129 into master (diff) | |
download | ceph-875a9dfed832ca77322defd822a4526b01c71d94.tar.xz ceph-875a9dfed832ca77322defd822a4526b01c71d94.zip |
common/PriorityCache: Automatic chunk sizing
Signed-off-by: Mark Nelson <mnelson@redhat.com>
Diffstat (limited to 'src/kv')
-rw-r--r-- | src/kv/KeyValueDB.h | 6 | ||||
-rw-r--r-- | src/kv/RocksDBStore.cc | 21 | ||||
-rw-r--r-- | src/kv/RocksDBStore.h | 5 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index bbea6119fed..dd3df17fab0 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -390,7 +390,11 @@ public: cache_bytes[pri] += bytes; } - virtual int64_t commit_cache_size() { + virtual int64_t commit_cache_size(uint64_t total_cache) { + return -EOPNOTSUPP; + } + + virtual int64_t get_committed_size() const { return -EOPNOTSUPP; } diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index 2f47cb5358f..7d858784ccf 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -1301,7 +1301,6 @@ int64_t RocksDBStore::request_cache_bytes(PriorityCache::Priority pri, uint64_t default: break; } - request = PriorityCache::get_chunk(usage, chunk_bytes); request = (request > assigned) ? request - assigned : 0; dout(10) << __func__ << " Priority: " << static_cast<uint32_t>(pri) << " Usage: " << usage << " Request: " << request << dendl; @@ -1313,28 +1312,26 @@ int64_t RocksDBStore::get_cache_usage() const return static_cast<int64_t>(bbt_opts.block_cache->GetUsage()); } -int64_t RocksDBStore::commit_cache_size() +int64_t RocksDBStore::commit_cache_size(uint64_t total_bytes) { size_t old_bytes = bbt_opts.block_cache->GetCapacity(); - int64_t total_bytes = get_cache_bytes(); + int64_t new_bytes = PriorityCache::get_chunk( + get_cache_bytes(), total_bytes); dout(10) << __func__ << " old: " << old_bytes - << " new: " << total_bytes << dendl; - bbt_opts.block_cache->SetCapacity((size_t) total_bytes); + << " new: " << new_bytes << dendl; + bbt_opts.block_cache->SetCapacity((size_t) new_bytes); // Set the high priority pool ratio is this is the binned LRU cache. if (g_conf()->rocksdb_cache_type == "binned_lru") { auto binned_cache = std::static_pointer_cast<rocksdb_cache::BinnedLRUCache>(bbt_opts.block_cache); - int64_t high_pri_bytes = get_cache_bytes(PriorityCache::Priority::PRI0); - double ratio = (double) high_pri_bytes / total_bytes; + int64_t high_pri_bytes = PriorityCache::get_chunk( + binned_cache->GetHighPriPoolUsage()+1, total_bytes); + double ratio = (double) high_pri_bytes / new_bytes; dout(10) << __func__ << " High Pri Pool Ratio set to " << ratio << dendl; binned_cache->SetHighPriPoolRatio(ratio); } - return total_bytes; -} - -int64_t RocksDBStore::get_cache_capacity() { - return bbt_opts.block_cache->GetCapacity(); + return new_bytes; } RocksDBStore::RocksDBWholeSpaceIteratorImpl::~RocksDBWholeSpaceIteratorImpl() diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h index 041474138c1..5354285be1d 100644 --- a/src/kv/RocksDBStore.h +++ b/src/kv/RocksDBStore.h @@ -480,7 +480,10 @@ err: virtual int64_t request_cache_bytes( PriorityCache::Priority pri, uint64_t cache_bytes) const override; - virtual int64_t commit_cache_size() override; + virtual int64_t commit_cache_size(uint64_t total_cache) override; + virtual int64_t get_committed_size() const override { + return bbt_opts.block_cache->GetCapacity(); + } virtual std::string get_cache_name() const override { return "RocksDB Block Cache"; } |