- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9.1k
HDFS-16648. Add isDebugEnabled check for debug logs in some classes #4529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 💔 -1 overall 
 
 This message was automatically generated. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we saving anything by checking LOG.isDebugEnabled()? Using {} should avoid toString() and all.
        
          
                hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this check.
With the new style line limit this could fit in one line too.
| 
 In PR-4480, I do a performance stress test about it. And found that adding isDebugEnabled before strings concatenation is helpful for performance. And the result is: 
 | 
| Thanks @ZanderXu for the benchmark. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new checkstyle, the string fits in one line without splitting:
blockLog.debug("BLOCK* removeStoredBlock: {} has already been removed from node {}",
    storedBlock, node);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string fits in one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string fits in one line if you do:
LOG.debug(
    "Failed to choose with favored nodes (={}), disregard favored nodes hint and retry.",
    favoredNodes, nr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string fits in one line.
| 💔 -1 overall 
 
 This message was automatically generated. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular one should stay within the isDebugEnabled() to avoid the mapToString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should stay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to keep the check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a judgment, so we can remove the internal redundant judgment.
if (blockLog.isDebugEnabled()) {
   for (Block b : invalidatedBlocks) {
      blockLog.debug("BLOCK* processReport 0x{} with lease ID 0x{}: {} on node {} size {} " +
                "does not belong to any file.", strBlockReportId, fullBrLeaseId, b,
          node, b.getNumBytes());
    }
}
| @goiri thanks for your review, I learned a lot and have updated the patch. Please help me review it again. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
        
          
                ...t/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumJournalManager.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 💔 -1 overall 
 
 This message was automatically generated. | 
| 
 @slfan1989 Thanks for your review. If you have any other questions or good ideas, please let me know. Thanks | 
| @slfan1989 ping. Can you push this PR forward? | 
        
          
                hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
 This pr looks good, let's wait for the opinions of other partners. thanks for your contribution! | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also remove isDebugEnabled from those. 2 lines
        
          
                hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...t/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumJournalManager.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | @ZanderXu After completing this pr, can you help summarize the precautions in the process of using logger, so that other partners can refer to it later? | 
| can remove isDebugEnabled from those clauses without '+' | 
| 
 Do you mean correct all classes in hadoop-hdfs module? In this patch, I just modified the classes that are used frequently by the namenode. | 
| 
 @slfan1989 Sure, I will summarize it. | 
| 
 can correct them in the classes you modified. | 
| Copy, I will correct them. Thanks~ | 
| 
 @ferhui I have corrected them, please help me review it again. Thanks~ | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
| @ZanderXu could you rebase the patch? | 
| @ferhui Thanks for your review. I have updated this patch based on the latest trunk. Please help me review it again, thanks. | 
| 💔 -1 overall 
 
 This message was automatically generated. | 
| @ZanderXu CI reported that 'This branch has conflicts that must be resolved' | 
| @ferhui Sir, thanks for your review. 
 I have fixed this conflict.  This conflict is in  | 
| 💔 -1 overall 
 
 
 This message was automatically generated. | 
| The failed UT  | 
| @ZanderXu Thanks for your contribution! @goiri @slfan1989 Thanks for your review! Merged | 
Refer to PR4480 to uniformly the debug logs in HDFS core classes.
And the detailed performance test, please refer to debugLogPerformanceTest.