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:
Sage Weil 2017-06-08 12:14:39 -04:00
parent c7464183ea
commit d94fce0286
3 changed files with 17 additions and 4 deletions

View File

@ -304,6 +304,10 @@ public:
return -EOPNOTSUPP;
}
virtual int set_cache_size(uint64_t) {
return -EOPNOTSUPP;
}
virtual ~KeyValueDB() {}
/// compact the underlying store

View File

@ -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));

View File

@ -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;