Skip to content

Commit

Permalink
Add counters for SST File reads/blocks in MultiGet. (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetrov4 authored Dec 8, 2023
1 parent f4ecc86 commit 376b44f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
30 changes: 30 additions & 0 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2521,9 +2521,17 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,
if (fp.GetHitFileLevel() == 0) {
dump_stats_for_l0_file = true;
}
// RocksDB-Cloud contribution begin
RecordTick(db_statistics_, MULTIGET_SST_FILE_READ_COUNT, 1);
// RocksDB-Cloud contribution end
}
if (s.ok()) {
f = fp.GetNextFileInLevel();
// RocksDB-Cloud contribution begin
if (f) {
RecordTick(db_statistics_, MULTIGET_SST_SERIALIZED_FILE_READ_COUNT, 1);
}
// RocksDB-Cloud contribution end
}
#if USE_COROUTINES
} else {
Expand Down Expand Up @@ -2567,6 +2575,9 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,
if (mget_tasks.size() > 0) {
RecordTick(db_statistics_, MULTIGET_COROUTINE_COUNT,
mget_tasks.size());
// RocksDB-Cloud contribution begin
RecordTick(db_statistics_, MULTIGET_SST_FILE_READ_COUNT, mget_tasks.size());
// RocksDB-Cloud contribution end
// Collect all results so far
std::vector<Status> statuses = folly::coro::blockingWait(
folly::coro::collectAllRange(std::move(mget_tasks))
Expand All @@ -2582,6 +2593,12 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,

if (s.ok() && fp.KeyMaySpanNextFile()) {
f = fp.GetNextFileInLevel();
// RocksDB-Cloud contribution begin
if (f) {
RecordTick(db_statistics_,
MULTIGET_SST_SERIALIZED_FILE_READ_COUNT, 1);
}
// RocksDB-Cloud contribution end
}
}
#endif // USE_COROUTINES
Expand Down Expand Up @@ -2763,6 +2780,10 @@ Status Version::ProcessBatch(
table_handle, std::get<0>(stat->second),
std::get<1>(stat->second),
std::get<2>(stat->second));
// RocksDB-Cloud contribution begin
RecordTick(db_statistics_,
MULTIGET_SST_FILE_READ_COUNT, mget_tasks.size());
// RocksDB-Cloud contribution end
} else {
mget_tasks.emplace_back(MultiGetFromSSTCoroutine(
read_options, file_range, fp.GetHitFileLevel(), skip_filters,
Expand Down Expand Up @@ -2853,6 +2874,10 @@ Status Version::MultiGetAsync(
if (mget_tasks.size() > 0) {
assert(waiting.size());
RecordTick(db_statistics_, MULTIGET_COROUTINE_COUNT, mget_tasks.size());
// RocksDB-Cloud contribution begin
RecordTick(db_statistics_,
MULTIGET_SST_FILE_READ_COUNT, mget_tasks.size());
// RocksDB-Cloud contribution end
// Collect all results so far
std::vector<Status> statuses = folly::coro::blockingWait(
folly::coro::collectAllRange(std::move(mget_tasks))
Expand All @@ -2879,6 +2904,11 @@ Status Version::MultiGetAsync(
// and no need to prepare the next level.
if (!fp.GetHitFile() && !fp.GetRange().empty()) {
fp.PrepareNextLevelForSearch();
} else {
// RocksDB-Cloud contribution begin
RecordTick(db_statistics_,
MULTIGET_SST_SERIALIZED_FILE_READ_COUNT, 1);
// RocksDB-Cloud contribution end
}
}
to_process.swap(waiting);
Expand Down
9 changes: 9 additions & 0 deletions include/rocksdb/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,15 @@ enum Tickers : uint32_t {
READ_ASYNC_MICROS,
// Number of errors returned to the async read callback
ASYNC_READ_ERROR_COUNT,

// RocksDB-Cloud contribution begin

// Total number of files read in MultiGet operations
MULTIGET_SST_FILE_READ_COUNT,
// Number of times file reads were serialized behind other reads
MULTIGET_SST_SERIALIZED_FILE_READ_COUNT,

// RocksDB-Cloud contribution end

TICKER_ENUM_MAX
};
Expand Down
8 changes: 7 additions & 1 deletion monitoring/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ const std::vector<std::pair<Tickers, std::string>> TickersNameMap = {
{BLOB_DB_CACHE_BYTES_READ, "rocksdb.blobdb.cache.bytes.read"},
{BLOB_DB_CACHE_BYTES_WRITE, "rocksdb.blobdb.cache.bytes.write"},
{READ_ASYNC_MICROS, "rocksdb.read.async.micros"},
{ASYNC_READ_ERROR_COUNT, "rocksdb.async.read.error.count"}};
{ASYNC_READ_ERROR_COUNT, "rocksdb.async.read.error.count"},
// RocksDB-Cloud contribution begin
{MULTIGET_SST_FILE_READ_COUNT, "rodksdb.number.multiget.sst_file_reads"},
{MULTIGET_SST_SERIALIZED_FILE_READ_COUNT,
"rocksdb.number.multiget.sst_serialized_file_reads"}
// RocksDB-Cloud contribution end
};

const std::vector<std::pair<Histograms, std::string>> HistogramsNameMap = {
{DB_GET, "rocksdb.db.get.micros"},
Expand Down

0 comments on commit 376b44f

Please sign in to comment.