diff --git a/db/db_impl.cc b/db/db_impl.cc index 5ac6956b1..294e0e4be 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2618,12 +2618,15 @@ Status DBImpl::GetImpl(const ReadOptions& options, LookupKey lkey(key, snapshot); if (mem->Get(lkey, value, &s, &merge_operands, options_)) { // Done + RecordTick(options_.statistics.get(), MEMTABLE_HIT); } else if (imm.Get(lkey, value, &s, &merge_operands, options_)) { // Done + RecordTick(options_.statistics.get(), MEMTABLE_HIT); } else { current->Get(options, lkey, value, &s, &merge_operands, &stats, options_, value_found); have_stat_update = true; + RecordTick(options_.statistics.get(), MEMTABLE_MISS); } mutex_.Lock(); diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 102a4be58..286a624c8 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -51,6 +51,11 @@ enum Tickers { // # of times bloom filter has avoided file reads. BLOOM_FILTER_USEFUL, + // # of memtable hits. + MEMTABLE_HIT, + // # of memtable misses. + MEMTABLE_MISS, + /** * COMPACTION_KEY_DROP_* count the reasons for key drop during compaction * There are 3 reasons currently. @@ -125,6 +130,8 @@ const std::vector> TickersNameMap = { { BLOCK_CACHE_DATA_MISS, "rocksdb.block.cache.data.miss" }, { BLOCK_CACHE_DATA_HIT, "rocksdb.block.cache.data.hit" }, { BLOOM_FILTER_USEFUL, "rocksdb.bloom.filter.useful" }, + { MEMTABLE_HIT, "rocksdb.memtable.hit" }, + { MEMTABLE_MISS, "rocksdb.memtable.miss" }, { COMPACTION_KEY_DROP_NEWER_ENTRY, "rocksdb.compaction.key.drop.new" }, { COMPACTION_KEY_DROP_OBSOLETE, "rocksdb.compaction.key.drop.obsolete" }, { COMPACTION_KEY_DROP_USER, "rocksdb.compaction.key.drop.user" },