mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
kv/RocksDBStore: allow cache_size to be specified explicitly
(Not via a config option) Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
c7464183ea
commit
d94fce0286
@ -304,6 +304,10 @@ public:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
virtual int set_cache_size(uint64_t) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
virtual ~KeyValueDB() {}
|
||||
|
||||
/// compact the underlying store
|
||||
|
@ -298,11 +298,14 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
|
||||
}
|
||||
|
||||
std::shared_ptr<rocksdb::Cache> cache;
|
||||
if (!cache_size) {
|
||||
cache_size = g_conf->rocksdb_cache_size;
|
||||
}
|
||||
if (g_conf->rocksdb_cache_type == "lru") {
|
||||
cache = rocksdb::NewLRUCache(g_conf->rocksdb_cache_size,
|
||||
cache = rocksdb::NewLRUCache(cache_size,
|
||||
g_conf->rocksdb_cache_shard_bits);
|
||||
} else if (g_conf->rocksdb_cache_type == "clock") {
|
||||
cache = rocksdb::NewClockCache(g_conf->rocksdb_cache_size,
|
||||
cache = rocksdb::NewClockCache(cache_size,
|
||||
g_conf->rocksdb_cache_shard_bits);
|
||||
} else {
|
||||
derr << "unrecognized rocksdb_cache_type '" << g_conf->rocksdb_cache_type
|
||||
@ -320,8 +323,8 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
|
||||
}
|
||||
opt.table_factory.reset(rocksdb::NewBlockBasedTableFactory(bbt_opts));
|
||||
dout(10) << __func__ << " set block size to " << g_conf->rocksdb_block_size
|
||||
<< " cache size to " << g_conf->rocksdb_cache_size
|
||||
<< " num of cache shards to "
|
||||
<< ", cache size to " << prettybyte_t(cache_size)
|
||||
<< ", cache shards to "
|
||||
<< (1 << g_conf->rocksdb_cache_shard_bits) << dendl;
|
||||
|
||||
opt.merge_operator.reset(new MergeOperatorRouter(*this));
|
||||
|
@ -75,6 +75,8 @@ class RocksDBStore : public KeyValueDB {
|
||||
rocksdb::BlockBasedTableOptions bbt_opts;
|
||||
string options_str;
|
||||
|
||||
uint64_t cache_size = 0;
|
||||
|
||||
int do_open(ostream &out, bool create_if_missing);
|
||||
|
||||
// manage async compactions
|
||||
@ -435,6 +437,10 @@ err:
|
||||
return total_size;
|
||||
}
|
||||
|
||||
int set_cache_size(uint64_t s) override {
|
||||
cache_size = s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
WholeSpaceIterator _get_iterator() override;
|
||||
|
Loading…
Reference in New Issue
Block a user