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

Erik Steffl commented on HADOOP-6884:
-------------------------------------

To put things in perspective:

  - the practice of using isDebugEnabled() is already common in Hadoop code, 
this patch just makes it more consistent

  - HDFS 187 in patch, 86 before patch

  - Common 63 in patch, 52 before patch

Note: patch adds isDebugEnabled to tests as well so the counts that matter are 
even lower.

None of the proposed solutions is solving all the problems and none of them is 
a short term solution. The only complaint against the patch is that it looks 
inelegant but from the discussion in this bug (and looking up others' effort to 
do the same) there's really no elegant solution for this problem in Java.

Claiming that patch adds code is a bit tricky. Yes it adds to total code 
written but in production runs it means less code being executed and less 
objects created (in alternative proposals even if the objects are not 
stringified they are still created). Given that we already have problems with 
GC that seems like a good idea.

We can still work on a long term better solution, once we have one we would 
have to convert all the code to the new solution anyway (at least remove 
already existing isDebugEnabled calls). Patch does not add significant 
(possibly none) additional work for that case.

> 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: FunAgain.java, FunAgain.java, 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