haridsv commented on code in PR #7136: URL: https://github.com/apache/hbase/pull/7136#discussion_r2185274903
########## hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SegmentScanner.java: ########## @@ -336,22 +337,40 @@ private Segment getSegment() { */ protected void updateCurrent() { ExtendedCell next = null; + boolean isScanMetricsEnabled = ThreadLocalServerSideScanMetrics.isScanMetricsEnabled(); + int totalBytesRead = 0; try { while (iter.hasNext()) { next = iter.next(); + if (isScanMetricsEnabled) { + // Batch collect bytes to reduce method call overhead + totalBytesRead += Segment.getCellLength(next); + } if (next.getSequenceId() <= this.readPoint) { current = next; + // Add accumulated bytes before returning + if (isScanMetricsEnabled && totalBytesRead > 0) { + ThreadLocalServerSideScanMetrics.addBytesReadFromMemstore(totalBytesRead); + } return;// skip irrelevant versions } // for backwardSeek() stay in the boundaries of a single row if (stopSkippingKVsIfNextRow && segment.compareRows(next, stopSkippingKVsRow) > 0) { current = null; + // Add accumulated bytes before returning + if (isScanMetricsEnabled && totalBytesRead > 0) { + ThreadLocalServerSideScanMetrics.addBytesReadFromMemstore(totalBytesRead); + } return; } } // end of while current = null; // nothing found + // Add accumulated bytes at the end + if (isScanMetricsEnabled && totalBytesRead > 0) { + ThreadLocalServerSideScanMetrics.addBytesReadFromMemstore(totalBytesRead); + } Review Comment: OK, I misread it, but I guess this can also go away if you follow my above recommendation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org