Skip to content

Commit

Permalink
Expand PerfContext to add ss_file reads and serialized_reads.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetrov4 committed Dec 11, 2023
1 parent e427394 commit 3a4dc81
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
33 changes: 33 additions & 0 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2521,9 +2521,19 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,
if (fp.GetHitFileLevel() == 0) {
dump_stats_for_l0_file = true;
}
// RocksDB-Cloud contribution begin
PERF_COUNTER_ADD(multiget_sst_file_read_count, 1);
// RocksDB-Cloud contribution end
}
if (s.ok()) {
f = fp.GetNextFileInLevel();
// RocksDB-Cloud contribution begin
if (f) {
// We have another file to read. This implies that the read on
// this file was blocked (or serialized) behind the previous read.
PERF_COUNTER_ADD(multiget_sst_serialized_file_read_count, 1);
}
// RocksDB-Cloud contribution end
}
#if USE_COROUTINES
} else {
Expand Down Expand Up @@ -2567,6 +2577,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
PERF_COUNTER_ADD(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 +2595,13 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,

if (s.ok() && fp.KeyMaySpanNextFile()) {
f = fp.GetNextFileInLevel();
// RocksDB-Cloud contribution begin
if (f) {
// We couldn't read all the files in this level 'in one go'.
// Record the number of files that were waiting.
PERF_COUNTER_ADD(multiget_sst_serialized_file_read_count, 1);
}
// RocksDB-Cloud contribution end
}
}
#endif // USE_COROUTINES
Expand Down Expand Up @@ -2763,6 +2783,9 @@ Status Version::ProcessBatch(
table_handle, std::get<0>(stat->second),
std::get<1>(stat->second),
std::get<2>(stat->second));
// RocksDB-Cloud contribution begin
PERF_COUNTER_ADD(multiget_sst_file_read_count, 1);
// RocksDB-Cloud contribution end
} else {
mget_tasks.emplace_back(MultiGetFromSSTCoroutine(
read_options, file_range, fp.GetHitFileLevel(), skip_filters,
Expand Down Expand Up @@ -2853,6 +2876,9 @@ Status Version::MultiGetAsync(
if (mget_tasks.size() > 0) {
assert(waiting.size());
RecordTick(db_statistics_, MULTIGET_COROUTINE_COUNT, mget_tasks.size());
// RocksDB-Cloud contribution begin
PERF_COUNTER_ADD(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 +2905,13 @@ Status Version::MultiGetAsync(
// and no need to prepare the next level.
if (!fp.GetHitFile() && !fp.GetRange().empty()) {
fp.PrepareNextLevelForSearch();
} else {
// RocksDB-Cloud contribution begin
// We still need to read files in the current level despite running
// some rounds of coroutine parallel reads. Record the fact that
// file reads were serialized.
PERF_COUNTER_ADD(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/perf_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ struct PerfContext {
uint64_t filter_block_read_count; // total number of filter block reads
uint64_t compression_dict_block_read_count; // total number of compression
// dictionary block reads

// RocksDB-Cloud contribution begin

// Total number of files read in MultiGet operations
uint64_t multiget_sst_file_read_count;
// Number of times file reads were serialized behind other reads
uint64_t multiget_sst_serialized_file_read_count;

// RocksDB-Cloud contribution end

uint64_t secondary_cache_hit_count; // total number of secondary cache hits
// total number of real handles inserted into secondary cache
Expand Down
33 changes: 33 additions & 0 deletions monitoring/perf_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ PerfContext::PerfContext(const PerfContext& other) {
block_cache_filter_hit_count = other.block_cache_filter_hit_count;
filter_block_read_count = other.filter_block_read_count;
compression_dict_block_read_count = other.compression_dict_block_read_count;

// RocksDB-Cloud contribution begin
multiget_sst_file_read_count = other.multiget_sst_file_read_count;
multiget_sst_serialized_file_read_count =
other.multiget_sst_serialized_file_read_count;
// RocksDB-Cloud contribution end

secondary_cache_hit_count = other.secondary_cache_hit_count;
compressed_sec_cache_insert_real_count =
other.compressed_sec_cache_insert_real_count;
Expand Down Expand Up @@ -162,6 +169,13 @@ PerfContext::PerfContext(PerfContext&& other) noexcept {
block_cache_filter_hit_count = other.block_cache_filter_hit_count;
filter_block_read_count = other.filter_block_read_count;
compression_dict_block_read_count = other.compression_dict_block_read_count;

// RocksDB-Cloud contribution begin
multiget_sst_file_read_count = other.multiget_sst_file_read_count;
multiget_sst_serialized_file_read_count =
other.multiget_sst_serialized_file_read_count;
// RocksDB-Cloud contribution end

secondary_cache_hit_count = other.secondary_cache_hit_count;
compressed_sec_cache_insert_real_count =
other.compressed_sec_cache_insert_real_count;
Expand Down Expand Up @@ -283,6 +297,13 @@ PerfContext& PerfContext::operator=(const PerfContext& other) {
block_cache_filter_hit_count = other.block_cache_filter_hit_count;
filter_block_read_count = other.filter_block_read_count;
compression_dict_block_read_count = other.compression_dict_block_read_count;

// RocksDB-Cloud contribution begin
multiget_sst_file_read_count = other.multiget_sst_file_read_count;
multiget_sst_serialized_file_read_count =
other.multiget_sst_serialized_file_read_count;
// RocksDB-Cloud contribution end

secondary_cache_hit_count = other.secondary_cache_hit_count;
compressed_sec_cache_insert_real_count =
other.compressed_sec_cache_insert_real_count;
Expand Down Expand Up @@ -400,6 +421,12 @@ void PerfContext::Reset() {
block_cache_filter_hit_count = 0;
filter_block_read_count = 0;
compression_dict_block_read_count = 0;

// RocksDB-Cloud contribution begin
multiget_sst_file_read_count = 0;
multiget_sst_serialized_file_read_count = 0;
// RocksDB-Cloud contribution end

secondary_cache_hit_count = 0;
compressed_sec_cache_insert_real_count = 0;
compressed_sec_cache_insert_dummy_count = 0;
Expand Down Expand Up @@ -536,6 +563,12 @@ std::string PerfContext::ToString(bool exclude_zero_counters) const {
PERF_CONTEXT_OUTPUT(block_cache_filter_hit_count);
PERF_CONTEXT_OUTPUT(filter_block_read_count);
PERF_CONTEXT_OUTPUT(compression_dict_block_read_count);

// RocksDB-Cloud contribution begin
PERF_CONTEXT_OUTPUT(multiget_sst_file_read_count);
PERF_CONTEXT_OUTPUT(multiget_sst_serialized_file_read_count);
// RocksDB-Cloud contribution end

PERF_CONTEXT_OUTPUT(secondary_cache_hit_count);
PERF_CONTEXT_OUTPUT(compressed_sec_cache_insert_real_count);
PERF_CONTEXT_OUTPUT(compressed_sec_cache_insert_dummy_count);
Expand Down

0 comments on commit 3a4dc81

Please sign in to comment.