]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: allow cache_size to be specified explicitly
authorSage Weil <sage@redhat.com>
Thu, 8 Jun 2017 16:14:39 +0000 (12:14 -0400)
committerSage Weil <sage@redhat.com>
Fri, 9 Jun 2017 13:30:42 +0000 (09:30 -0400)
(Not via a config option)

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

index 9f454ac973aeeb2459cbd7993a660db3df39183c..37a78480f140814a26ccdb72d59521828bf9ed43 100644 (file)
@@ -304,6 +304,10 @@ public:
     return -EOPNOTSUPP;
   }
 
+  virtual int set_cache_size(uint64_t) {
+    return -EOPNOTSUPP;
+  }
+
   virtual ~KeyValueDB() {}
 
   /// compact the underlying store
index c6d3e5e553fc238a60921621bd78d34ad0cb49a1..db985f0aa6ef574c3418f3b50680890770f2e8ef 100644 (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));
index 4d25408a5f00405afa03538db0017162c26d1fc8..c437badebabbbf76887094ec2c53fe0aae00a3ef 100644 (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;