Skip to content

Commit 91d0feb

Browse files
HBASE-29099 Avoid expensive BlockCacheKey.toString() calls when tracing is disabled (#6642) (#6645)
Signed-off-by: Ray Mattingly <[email protected]> Co-authored-by: jbewing <[email protected]>
1 parent bd3a20f commit 91d0feb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,11 +1289,15 @@ public HFileBlock readBlock(long dataBlockOffset, long onDiskBlockSize, final bo
12891289

12901290
BlockCacheKey cacheKey =
12911291
new BlockCacheKey(path, dataBlockOffset, this.isPrimaryReplicaReader(), expectedBlockType);
1292-
Attributes attributes = Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString());
12931292

12941293
boolean useLock = false;
12951294
IdLock.Entry lockEntry = null;
12961295
final Span span = Span.current();
1296+
// BlockCacheKey#toString() is quite expensive to call, so if tracing isn't enabled, don't
1297+
// record
1298+
Attributes attributes = span.isRecording()
1299+
? Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString())
1300+
: Attributes.empty();
12971301
try {
12981302
while (true) {
12991303
// Check cache for block. If found return.

0 commit comments

Comments
 (0)