diff --git a/HISTORY.md b/HISTORY.md index 771e25f16..5dbf7b83d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ ### Public API Change * Add a BlockBasedTableOption to align uncompressed data blocks on the smaller of block size or page size boundary, to reduce flash reads by avoiding reads spanning 4K pages. * The background thread naming convention changed (on supporting platforms) to "rocksdb:", e.g., "rocksdb:low0". +* Add a new ticker stat rocksdb.number.multiget.keys.found to count number of keys successfully read in MultiGet calls ### New Features * Introduce TTL for level compaction so that all files older than ttl go through the compaction process to get rid of old data. diff --git a/db/db_impl.cc b/db/db_impl.cc index 1c8e9de8e..1972f33b9 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1164,6 +1164,7 @@ std::vector DBImpl::MultiGet( // First look in the memtable, then in the immutable memtable (if any). // s is both in/out. When in, s could either be OK or MergeInProgress. // merge_operands will contain the sequence of merges in the latter case. + size_t num_found = 0; for (size_t i = 0; i < num_keys; ++i) { merge_context.Clear(); Status& s = stat_list[i]; @@ -1185,11 +1186,11 @@ std::vector DBImpl::MultiGet( if (super_version->mem->Get(lkey, value, &s, &merge_context, &range_del_agg, read_options)) { done = true; - // TODO(?): RecordTick(stats_, MEMTABLE_HIT)? + RecordTick(stats_, MEMTABLE_HIT); } else if (super_version->imm->Get(lkey, value, &s, &merge_context, &range_del_agg, read_options)) { done = true; - // TODO(?): RecordTick(stats_, MEMTABLE_HIT)? + RecordTick(stats_, MEMTABLE_HIT); } } if (!done) { @@ -1198,11 +1199,12 @@ std::vector DBImpl::MultiGet( super_version->current->Get(read_options, lkey, &pinnable_val, &s, &merge_context, &range_del_agg); value->assign(pinnable_val.data(), pinnable_val.size()); - // TODO(?): RecordTick(stats_, MEMTABLE_MISS)? + RecordTick(stats_, MEMTABLE_MISS); } if (s.ok()) { bytes_read += value->size(); + num_found++; } } @@ -1230,6 +1232,7 @@ std::vector DBImpl::MultiGet( RecordTick(stats_, NUMBER_MULTIGET_CALLS); RecordTick(stats_, NUMBER_MULTIGET_KEYS_READ, num_keys); + RecordTick(stats_, NUMBER_MULTIGET_KEYS_FOUND, num_found); RecordTick(stats_, NUMBER_MULTIGET_BYTES_READ, bytes_read); MeasureTime(stats_, BYTES_PER_MULTIGET, bytes_read); PERF_COUNTER_ADD(multiget_read_bytes, bytes_read); diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 828a4d0ea..1a4f699db 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -320,6 +320,9 @@ enum Tickers : uint32_t { // # of times snapshot_mutex_ is acquired in the fast path. TXN_SNAPSHOT_MUTEX_OVERHEAD, + // Number of keys actually found in MultiGet calls (vs number requested by caller) + // NUMBER_MULTIGET_KEYS_READ gives the number requested by caller + NUMBER_MULTIGET_KEYS_FOUND, TICKER_ENUM_MAX }; @@ -471,6 +474,7 @@ const std::vector> TickersNameMap = { "rocksdb.txn.overhead.mutex.old.commit.map"}, {TXN_DUPLICATE_KEY_OVERHEAD, "rocksdb.txn.overhead.duplicate.key"}, {TXN_SNAPSHOT_MUTEX_OVERHEAD, "rocksdb.txn.overhead.mutex.snapshot"}, + {NUMBER_MULTIGET_KEYS_FOUND, "rocksdb.number.multiget.keys.found"}, }; /** diff --git a/java/rocksjni/portal.h b/java/rocksjni/portal.h index f809184c1..29ba32070 100644 --- a/java/rocksjni/portal.h +++ b/java/rocksjni/portal.h @@ -3295,8 +3295,10 @@ class TickerTypeJni { return 0x5C; case rocksdb::Tickers::NUMBER_ITER_SKIP: return 0x5D; - case rocksdb::Tickers::TICKER_ENUM_MAX: + case rocksdb::Tickers::NUMBER_MULTIGET_KEYS_FOUND: return 0x5E; + case rocksdb::Tickers::TICKER_ENUM_MAX: + return 0x5F; default: // undefined/default @@ -3497,6 +3499,8 @@ class TickerTypeJni { case 0x5D: return rocksdb::Tickers::NUMBER_ITER_SKIP; case 0x5E: + return rocksdb::Tickers::NUMBER_MULTIGET_KEYS_FOUND; + case 0x5F: return rocksdb::Tickers::TICKER_ENUM_MAX; default: diff --git a/java/src/main/java/org/rocksdb/TickerType.java b/java/src/main/java/org/rocksdb/TickerType.java index 948079c75..fdcf62ff8 100644 --- a/java/src/main/java/org/rocksdb/TickerType.java +++ b/java/src/main/java/org/rocksdb/TickerType.java @@ -465,7 +465,17 @@ public enum TickerType { */ NUMBER_RATE_LIMITER_DRAINS((byte) 0x5C), - TICKER_ENUM_MAX((byte) 0x5D); + /** + * Number of internal skipped during iteration + */ + NUMBER_ITER_SKIP((byte) 0x5D), + + /** + * Number of MultiGet keys found (vs number requested) + */ + NUMBER_MULTIGET_KEYS_FOUND((byte) 0x5E), + + TICKER_ENUM_MAX((byte) 0x5F); private final byte value;