OPTION(rocksdb_log_to_ceph_log, OPT_BOOL, true) // log to ceph log
OPTION(rocksdb_cache_size, OPT_U64, 128*1024*1024) // default rocksdb cache size
OPTION(rocksdb_cache_shard_bits, OPT_INT, 4) // rocksdb block cache shard bits, 4 bit -> 16 shards
+OPTION(rocksdb_cache_type, OPT_STR, "lru") // 'lru' or 'clock'
OPTION(rocksdb_block_size, OPT_INT, 4*1024) // default rocksdb block size
OPTION(rocksdb_perf, OPT_BOOL, false) // Enabling this will have 5-10% impact on performance for the stats collection
OPTION(rocksdb_collect_compaction_stats, OPT_BOOL, false) //For rocksdb, this behavior will be an overhead of 5%~10%, collected only rocksdb_perf is enabled.
opt.env = static_cast<rocksdb::Env*>(priv);
}
- auto cache = rocksdb::NewLRUCache(g_conf->rocksdb_cache_size, g_conf->rocksdb_cache_shard_bits);
+ std::shared_ptr<rocksdb::Cache> cache;
+ if (g_conf->rocksdb_cache_type == "lru") {
+ cache = rocksdb::NewLRUCache(g_conf->rocksdb_cache_size,
+ g_conf->rocksdb_cache_shard_bits);
+ } else if (g_conf->rocksdb_cache_type == "clock") {
+ cache = rocksdb::NewClockCache(g_conf->rocksdb_cache_size,
+ g_conf->rocksdb_cache_shard_bits);
+ } else {
+ derr << "unrecognized rocksdb_cache_type '" << g_conf->rocksdb_cache_type
+ << "'" << dendl;
+ return -EINVAL;
+ }
+
bbt_opts.block_size = g_conf->rocksdb_block_size;
bbt_opts.block_cache = cache;
if (g_conf->kstore_rocksdb_bloom_bits_per_key > 0) {
dout(10) << __func__ << " set bloom filter bits per key to "
<< g_conf->kstore_rocksdb_bloom_bits_per_key << dendl;
- bbt_opts.filter_policy.reset(rocksdb::NewBloomFilterPolicy(g_conf->kstore_rocksdb_bloom_bits_per_key));
+ bbt_opts.filter_policy.reset(rocksdb::NewBloomFilterPolicy(
+ g_conf->kstore_rocksdb_bloom_bits_per_key));
}
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 " << (1 << g_conf->rocksdb_cache_shard_bits) << dendl;
+ << " num of cache shards to "
+ << (1 << g_conf->rocksdb_cache_shard_bits) << dendl;
opt.merge_operator.reset(new MergeOperatorRouter(*this));
status = rocksdb::DB::Open(opt, path, &db);