]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
New PerfContext counters for block cache bytes read (#12459)
authoranand76 <anand1976@users.noreply.github.com>
Thu, 21 Mar 2024 17:46:46 +0000 (10:46 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 21 Mar 2024 17:46:46 +0000 (10:46 -0700)
Summary:
Add PerfContext counters for measuring the cumulative size of blocks found in the block cache.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12459

Reviewed By: ajkr

Differential Revision: D55170694

Pulled By: anand1976

fbshipit-source-id: 8cbba76eece116cefce7f00e2fc9d74757661d25

include/rocksdb/perf_context.h
java/rocksjni/jni_perf_context.cc
monitoring/perf_context.cc
table/block_based/block_based_table_reader.cc
unreleased_history/public_api_changes/new_block_cache_perf_counters.md [new file with mode: 0644]

index 46266abbaabaaa4f8049fedea1c027c69f95f39f..80792131cf700cad91833d71088bd74d845940e1 100644 (file)
@@ -83,6 +83,11 @@ struct PerfContextBase {
   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
+  // Cumulative size of blocks found in block cache
+  uint64_t block_cache_index_read_byte;
+  uint64_t block_cache_filter_read_byte;
+  uint64_t block_cache_compression_dict_read_byte;
+  uint64_t block_cache_read_byte;
 
   uint64_t secondary_cache_hit_count;  // total number of secondary cache hits
   // total number of real handles inserted into secondary cache
index e0124fdaa282022e0be951f89197932d11fb54f7..8ef5c7d369f8b3f25e439d93871932bb6abea690 100644 (file)
@@ -167,6 +167,54 @@ jlong Java_org_rocksdb_PerfContext_getBlockReadCpuTime(JNIEnv*, jobject,
   return perf_context->block_read_cpu_time;
 }
 
+/*
+ * Class:     org_rocksdb_PerfContext
+ * Method:    getBlockCacheIndexReadByte
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_PerfContext_getBlockCacheIndexReadByte(
+    JNIEnv*, jobject, jlong jpc_handle) {
+  ROCKSDB_NAMESPACE::PerfContext* perf_context =
+      reinterpret_cast<ROCKSDB_NAMESPACE::PerfContext*>(jpc_handle);
+  return perf_context->block_cache_index_read_byte;
+}
+
+/*
+ * Class:     org_rocksdb_PerfContext
+ * Method:    getBlockCacheFilterReadByte
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_PerfContext_getBlockCacheFilterReadByte(
+    JNIEnv*, jobject, jlong jpc_handle) {
+  ROCKSDB_NAMESPACE::PerfContext* perf_context =
+      reinterpret_cast<ROCKSDB_NAMESPACE::PerfContext*>(jpc_handle);
+  return perf_context->block_cache_filter_read_byte;
+}
+
+/*
+ * Class:     org_rocksdb_PerfContext
+ * Method:    getBlockCacheCompressionDictReadByte
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_PerfContext_getBlockCacheCompressionDictReadByte(
+    JNIEnv*, jobject, jlong jpc_handle) {
+  ROCKSDB_NAMESPACE::PerfContext* perf_context =
+      reinterpret_cast<ROCKSDB_NAMESPACE::PerfContext*>(jpc_handle);
+  return perf_context->block_cache_compression_dict_read_byte;
+}
+
+/*
+ * Class:     org_rocksdb_PerfContext
+ * Method:    getBlockCacheReadByte
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_PerfContext_getBlockCacheReadByte(JNIEnv*, jobject,
+                                                         jlong jpc_handle) {
+  ROCKSDB_NAMESPACE::PerfContext* perf_context =
+      reinterpret_cast<ROCKSDB_NAMESPACE::PerfContext*>(jpc_handle);
+  return perf_context->block_cache_read_byte;
+}
+
 /*
  * Class:     org_rocksdb_PerfContext
  * Method:    getSecondaryCacheHitCount
index 6839e905983e4f93c72e2b52f4f989c353e69af3..2f25f68c238560d11955a993b21e18d86099afd0 100644 (file)
@@ -62,6 +62,10 @@ struct PerfContextByLevelInt {
   defCmd(block_cache_filter_hit_count)             \
   defCmd(filter_block_read_count)                  \
   defCmd(compression_dict_block_read_count)        \
+  defCmd(block_cache_index_read_byte)              \
+  defCmd(block_cache_filter_read_byte)             \
+  defCmd(block_cache_compression_dict_read_byte)   \
+  defCmd(block_cache_read_byte)                    \
   defCmd(secondary_cache_hit_count)                \
   defCmd(compressed_sec_cache_insert_real_count)   \
   defCmd(compressed_sec_cache_insert_dummy_count)  \
index b46619eddc9229ff4edc7985253df4b78e1e6989..e85a8bff4c3013cea034b28d23ebe0030d30a020 100644 (file)
@@ -217,6 +217,7 @@ void BlockBasedTable::UpdateCacheHitMetrics(BlockType block_type,
   Statistics* const statistics = rep_->ioptions.stats;
 
   PERF_COUNTER_ADD(block_cache_hit_count, 1);
+  PERF_COUNTER_ADD(block_cache_read_byte, usage);
   PERF_COUNTER_BY_LEVEL_ADD(block_cache_hit_count, 1,
                             static_cast<uint32_t>(rep_->level));
 
@@ -232,6 +233,7 @@ void BlockBasedTable::UpdateCacheHitMetrics(BlockType block_type,
     case BlockType::kFilter:
     case BlockType::kFilterPartitionIndex:
       PERF_COUNTER_ADD(block_cache_filter_hit_count, 1);
+      PERF_COUNTER_ADD(block_cache_filter_read_byte, usage);
 
       if (get_context) {
         ++get_context->get_context_stats_.num_cache_filter_hit;
@@ -242,6 +244,7 @@ void BlockBasedTable::UpdateCacheHitMetrics(BlockType block_type,
 
     case BlockType::kCompressionDictionary:
       // TODO: introduce perf counter for compression dictionary hit count
+      PERF_COUNTER_ADD(block_cache_compression_dict_read_byte, usage);
       if (get_context) {
         ++get_context->get_context_stats_.num_cache_compression_dict_hit;
       } else {
@@ -251,6 +254,7 @@ void BlockBasedTable::UpdateCacheHitMetrics(BlockType block_type,
 
     case BlockType::kIndex:
       PERF_COUNTER_ADD(block_cache_index_hit_count, 1);
+      PERF_COUNTER_ADD(block_cache_index_read_byte, usage);
 
       if (get_context) {
         ++get_context->get_context_stats_.num_cache_index_hit;
diff --git a/unreleased_history/public_api_changes/new_block_cache_perf_counters.md b/unreleased_history/public_api_changes/new_block_cache_perf_counters.md
new file mode 100644 (file)
index 0000000..70fe323
--- /dev/null
@@ -0,0 +1 @@
+Added new PerfContext counters for block cache bytes read - block_cache_index_read_byte, block_cache_filter_read_byte, block_cache_compression_dict_read_byte, and block_cache_read_byte.