[ 
https://issues.apache.org/jira/browse/HADOOP-6884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12899522#action_12899522
 ] 

Doug Cutting commented on HADOOP-6884:
--------------------------------------

Nicholas>  I have checked the slf4j Logger API but does find a method like that.

That's right.  I said, such an API "need not be a varargs call, but can a 
normal, 4-arg method call".  With slf4j it would be varrargs.  Also note, 
however, that the current patch doesn't contain any log examples with three 
parameters.

Scott> The autoboxing and varargs is significantly less expensive than string 
concatenation.
Scott> Sun's JVM will already avoid the varargs Object[] construction, and the 
Double, but not the Long or Integer, if +UseEscapeAnalysis is on. That flag 
becomes the default soon.

Good points, Scott.

This issue lacks benchmarks.  Proposed optimizations should include benchmarks. 
 The following article has comments that indicate that, as Scott suggests, 
autoboxing and varargs are pretty fast.  With escape analysis they might be 
even faster.

http://www.nearinfinity.com/blogs/jeff_kunkle/performance_of_guarding_debug_log.html

If someone adds debug log lines in performance sensitive code, e.g., when 
calculating CRC32 or somesuch, then explicitly calling isDebugEnabled() would 
probably be a significant optimization, but such cases are rare, and 
performance sensitive code should be modified cautiously anyway, since other 
minor changes can have big effects.

> Add LOG.isDebugEnabled() guard for each LOG.debug("...")
> --------------------------------------------------------
>
>                 Key: HADOOP-6884
>                 URL: https://issues.apache.org/jira/browse/HADOOP-6884
>             Project: Hadoop Common
>          Issue Type: Improvement
>    Affects Versions: 0.22.0
>            Reporter: Erik Steffl
>            Assignee: Erik Steffl
>             Fix For: 0.22.0
>
>         Attachments: HADOOP-6884-0.22-1.patch, HADOOP-6884-0.22.patch
>
>
> Each LOG.debug("...") should be executed only if LOG.isDebugEnabled() is 
> true, in some cases it's expensive to construct the string that is being 
> printed to log. It's much easier to always use LOG.isDebugEnabled() because 
> it's easier to check (rather than in each case reason whether it's necessary 
> or not).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to