Just a caveat: when there is conditional code like this based on the configured logging level, then testing should be done with different logging levels to verify that there are no side effects or exceptions (such as NPE) generated by these conditional code blocks. FWIW, this is not something I currently consider in my test matrix.
Nige On Mar 29, 2007, at 11:02 AM, Dhruba Borthakur wrote:
There are portions code in the Namenode: if (NameNode.stateChangeLog.isInfoEnabled()) { ... } -----Original Message----- From: Raghu Angadi [mailto:[EMAIL PROTECTED] Sent: Thursday, March 29, 2007 11:00 AM To: [email protected] Subject: Cost of debug statements. Is there a way to test to if debug is enabled before invoking a statement like : NameNode.stateChangeLog.debug("BLOCK* NameSystem.UnderReplicationBlock.add:"+ block.getBlockName() + " has only "+curReplicas + " replicas and need " + expectedReplicas + " replicas so is added to neededReplications" + " at priority level " + priLevel ); It looks like we pay the cost of constructing the string for this call all the time. This seems to involve multiple allocations anddeallocations, int to string conversions, and string concatenations etc. Since there are multiple such statements in various critical code paths on namenode, it could affect quite a bit of performance. Should we havesomething like : if ( debugEnabled ) { NameNode.stateChangeLog.debug( ... } Raghu.
