You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/04/05 21:21:00 UTC

[jira] [Work logged] (HDFS-16530) setReplication debug log creates a new string even if debug is disabled

     [ https://issues.apache.org/jira/browse/HDFS-16530?focusedWorklogId=753109&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-753109 ]

ASF GitHub Bot logged work on HDFS-16530:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Apr/22 21:20
            Start Date: 05/Apr/22 21:20
    Worklog Time Spent: 10m 
      Work Description: sodonnel opened a new pull request, #4142:
URL: https://github.com/apache/hadoop/pull/4142

   ### Description of PR
   
   In FSDirAttrOp, [HDFS-14521](https://issues.apache.org/jira/browse/HDFS-14521) made a good change to move a noisy logger to debug:
   
   ```
         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());
         }
       }
   ```
   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:
   ```
     public String getPath() {
       if (pathname == null) {
         pathname = DFSUtil.byteArray2PathString(path);
       }
       return pathname;
     }
   ```
   We should wrap the entire logging block in `if LOG.debugEnabled()` to avoid any overhead when the logger is not enabled.
   
   ### How was this patch tested?
   
   No new tests - simple change.
   
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 753109)
    Remaining Estimate: 0h
            Time Spent: 10m

> 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
>          Time Spent: 10m
>  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-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org