[
https://issues.apache.org/jira/browse/HDFS-16638?focusedWorklogId=784902&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-784902
]
ASF GitHub Bot logged work on HDFS-16638:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Jun/22 00:58
Start Date: 27/Jun/22 00:58
Worklog Time Spent: 10m
Work Description: virajjasani commented on PR #4480:
URL: https://github.com/apache/hadoop/pull/4480#issuecomment-1166705882
I am not sure if having `isLogEnabled()` would help with much perf
improvement so long as we use arguments `{}` to let the logger library take
care of the final String concat.
Looking at `slf4j-api` and `log4j-slf4j-impl`, Log4jLogger has this
implementation:
```
@Override
public void debug(final String format, final Object... args) {
logger.logIfEnabled(FQCN, Level.DEBUG, null, format, args);
}
```
which would call `log4j-api` implementation of `AbstractLogger`:
```
@Override
public void logIfEnabled(final String fqcn, final Level level, final
Marker marker, final String message,
final Object... params) {
if (isEnabled(level, marker, message, params)) {
logMessage(fqcn, level, marker, message, params);
}
}
```
Hence, as long as we use parameterized args `{}`, the final log concat
operation happens only if the logger level (DEBUG in our case) is enabled.
The best practice to use `isDebugEnabled` or `isTraceEnabled` is when we
don't use parameterized args `{}` and instead use full string concat all by
ourselves, in which case string cancat with big values happen regardless of
whether log level is enabled, but we are already using params for these
loggers, hence I don't think we would gain much here.
Thoughts?
Issue Time Tracking
-------------------
Worklog Id: (was: 784902)
Time Spent: 1h (was: 50m)
> Add isDebugEnabled check for debug blockLogs in BlockManager
> ------------------------------------------------------------
>
> Key: HDFS-16638
> URL: https://issues.apache.org/jira/browse/HDFS-16638
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: namenode
> Reporter: dzcxzl
> Priority: Trivial
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> There are lots of concatenating Strings using blockLog.debug in BlockManager.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]