[ https://issues.apache.org/jira/browse/HDFS-16530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stephen O'Donnell updated HDFS-16530: ------------------------------------- Fix Version/s: 3.2.4 > setReplication debug log creates a new string even if debug is disabled > ----------------------------------------------------------------------- > > Key: HDFS-16530 > URL: https://issues.apache.org/jira/browse/HDFS-16530 > Project: Hadoop HDFS > Issue Type: Improvement > Components: namenode > Reporter: Stephen O'Donnell > Assignee: Stephen O'Donnell > Priority: Major > Labels: pull-request-available > Fix For: 3.4.0, 3.2.4, 3.3.3 > > Time Spent: 40m > Remaining Estimate: 0h > > In FSDirAttrOp, HDFS-14521 made a good change to move a noisy logger to debug: > {code} > if (oldBR > targetReplication) { > FSDirectory.LOG.debug("Decreasing replication from {} to {} for {}", > oldBR, targetReplication, iip.getPath()); > } else if (oldBR < targetReplication) { > FSDirectory.LOG.debug("Increasing replication from {} to {} for {}", > oldBR, targetReplication, iip.getPath()); > } else { > FSDirectory.LOG.debug("Replication remains unchanged at {} for {}", > oldBR, iip.getPath()); > } > } > {code} > However the `iip.getPath()` method must be evaluated to pass the resulting > string into the LOG.debug method, even if debug is not enabled: > This code may form a new string where it does not need to: > {code} > public String getPath() { > if (pathname == null) { > pathname = DFSUtil.byteArray2PathString(path); > } > return pathname; > } > {code} > We should wrap the entire logging block in `if LOG.debugEnabled()` to avoid > any overhead when the logger is not enabled. -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org