]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: rocksdb_cache_row_ratio
authorSage Weil <sage@redhat.com>
Thu, 8 Jun 2017 17:01:45 +0000 (13:01 -0400)
committerSage Weil <sage@redhat.com>
Fri, 9 Jun 2017 14:50:55 +0000 (10:50 -0400)
Specify portion of cache to devote to row cache (the rest goes to the
block cache).

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/kv/RocksDBStore.cc

index c5806f86294318822eb8b5e873fa52e27601849a..ec3fa66ece380822916eece6ea65cdb609d99a33 100644 (file)
@@ -945,6 +945,7 @@ OPTION(rocksdb_separate_wal_dir, OPT_BOOL, false) // use $path.wal for wal
 SAFE_OPTION(rocksdb_db_paths, OPT_STR, "")   // path,size( path,size)*
 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_row_ratio, OPT_FLOAT, .2)   // ratio of cache for row (vs block)
 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
index db985f0aa6ef574c3418f3b50680890770f2e8ef..0ea96ca12381d04a783bd614e57637aa38e25498 100644 (file)
@@ -297,24 +297,30 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
     opt.env = static_cast<rocksdb::Env*>(priv);
   }
 
-  std::shared_ptr<rocksdb::Cache> cache;
+  // caches
   if (!cache_size) {
     cache_size = g_conf->rocksdb_cache_size;
   }
+  uint64_t row_cache_size = cache_size * g_conf->rocksdb_cache_row_ratio;
+  uint64_t block_cache_size = cache_size - row_cache_size;
   if (g_conf->rocksdb_cache_type == "lru") {
-    cache = rocksdb::NewLRUCache(cache_size,
-                                g_conf->rocksdb_cache_shard_bits);
+    bbt_opts.block_cache = rocksdb::NewLRUCache(
+      block_cache_size,
+      g_conf->rocksdb_cache_shard_bits);
   } else if (g_conf->rocksdb_cache_type == "clock") {
-    cache = rocksdb::NewClockCache(cache_size,
-                                  g_conf->rocksdb_cache_shard_bits);
+    bbt_opts.block_cache = rocksdb::NewClockCache(
+      block_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;
+
+  opt.row_cache = rocksdb::NewLRUCache(row_cache_size,
+                                      g_conf->rocksdb_cache_shard_bits);
+
   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;
@@ -322,10 +328,13 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
                                   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 " << prettybyte_t(cache_size)
-           << ", cache shards to "
-          << (1 << g_conf->rocksdb_cache_shard_bits) << dendl;
+  dout(10) << __func__ << " block size " << g_conf->rocksdb_block_size
+           << ", block_cache size " << prettybyte_t(block_cache_size)
+          << ", row_cache size " << prettybyte_t(row_cache_size)
+          << "; shards "
+          << (1 << g_conf->rocksdb_cache_shard_bits)
+          << ", type " << g_conf->rocksdb_cache_type
+          << dendl;
 
   opt.merge_operator.reset(new MergeOperatorRouter(*this));
   status = rocksdb::DB::Open(opt, path, &db);