You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by rm...@apache.org on 2025/01/31 23:28:05 UTC

(hbase) branch branch-2 updated: HBASE-29099 Avoid expensive BlockCacheKey.toString() calls when tracing is disabled (#6642) (#6646)

This is an automated email from the ASF dual-hosted git repository.

rmattingly pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new e1649945480 HBASE-29099 Avoid expensive BlockCacheKey.toString() calls when tracing is disabled (#6642) (#6646)
e1649945480 is described below

commit e164994548034c8a3ef6f37f02e09f4e78066d94
Author: Ray Mattingly <rm...@apache.org>
AuthorDate: Fri Jan 31 18:28:00 2025 -0500

    HBASE-29099 Avoid expensive BlockCacheKey.toString() calls when tracing is disabled (#6642) (#6646)
    
    Signed-off-by: Ray Mattingly <rm...@apache.org>
    Co-authored-by: jbewing <jb...@live.com>
---
 .../main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
index aacc4473787..c1522e4e433 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
@@ -1298,11 +1298,15 @@ public abstract class HFileReaderImpl implements HFile.Reader, Configurable {
 
     BlockCacheKey cacheKey =
       new BlockCacheKey(path, dataBlockOffset, this.isPrimaryReplicaReader(), expectedBlockType);
-    Attributes attributes = Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString());
 
     boolean useLock = false;
     IdLock.Entry lockEntry = null;
     final Span span = Span.current();
+    // BlockCacheKey#toString() is quite expensive to call, so if tracing isn't enabled, don't
+    // record
+    Attributes attributes = span.isRecording()
+      ? Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString())
+      : Attributes.empty();
     try {
       while (true) {
         // Check cache for block. If found return.