You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by cakofony <gi...@git.apache.org> on 2018/08/14 14:57:46 UTC
[GitHub] logging-log4j2 pull request #210: [LOG4J2-2391] Lazily initialize ThrowableP...
GitHub user cakofony opened a pull request:
https://github.com/apache/logging-log4j2/pull/210
[LOG4J2-2391] Lazily initialize ThrowableProxy data
Goal is to avoid the most expensive components until render
time, allowing patterns using non-extended traces to avoid
the cost of class loading.
This implementation is fairly naive in that initialization
will deeply initialize all causes and suppressed causes
when any action requires initialization, rather than
lazily initializing only what is required.
Benchmarking results with this change show that the
"complexLog4j2ThrowableAsync" performance matches
"complexLog4j2Throwable" due to avoiding ThrowableProxy
initialization.
```
Benchmark Mode Cnt Score Error Units
FileAppenderThrowableBenchmark.complexLog4j1 thrpt 3 8537.030 ± 5312.479 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ExtendedThrowable thrpt 3 2534.330 ± 600.769 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ExtendedThrowableAsync thrpt 3 2488.063 ± 838.325 ops/s
FileAppenderThrowableBenchmark.complexLog4j2Throwable thrpt 3 13206.010 ± 320.408 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ThrowableAsync thrpt 3 12795.284 ± 2677.436 ops/s
FileAppenderThrowableBenchmark.complexLogbackFile thrpt 3 11377.932 ± 25787.767 ops/s
FileAppenderThrowableBenchmark.julFile thrpt 3 54271.234 ± 42052.793 ops/s
FileAppenderThrowableBenchmark.log4j1 thrpt 3 75694.883 ± 13310.643 ops/s
FileAppenderThrowableBenchmark.log4j2ExtendedThrowable thrpt 3 46216.007 ± 1046.523 ops/s
FileAppenderThrowableBenchmark.log4j2Throwable thrpt 3 110604.119 ± 33981.960 ops/s
FileAppenderThrowableBenchmark.logbackFile thrpt 3 112429.311 ± 95759.913 ops/s
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/cakofony/logging-log4j2 ckozak/lazily_initialize_throwable_proxy
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/logging-log4j2/pull/210.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #210
----
commit 5f8b02d15babf556c7d698e91f7b873ceff711be
Author: Carter Kozak <ck...@...>
Date: 2018-08-13T21:14:29Z
[LOG4J2-2391] Lazily initialize ThrowableProxy data
Goal is to avoid the most expensive components until render
time, allowing patterns using non-extended traces to avoid
the cost of class loading.
This implementation is fairly naive in that initialization
will deeply initialize all causes and suppressed causes
when any action requires initialization, rather than
lazily initializing only what is required.
Benchmarking results with this change show that the
"complexLog4j2ThrowableAsync" performance matches
"complexLog4j2Throwable" due to avoiding ThrowableProxy
initialization.
Benchmark Mode Cnt Score Error Units
FileAppenderThrowableBenchmark.complexLog4j1 thrpt 3 8537.030 ± 5312.479 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ExtendedThrowable thrpt 3 2534.330 ± 600.769 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ExtendedThrowableAsync thrpt 3 2488.063 ± 838.325 ops/s
FileAppenderThrowableBenchmark.complexLog4j2Throwable thrpt 3 13206.010 ± 320.408 ops/s
FileAppenderThrowableBenchmark.complexLog4j2ThrowableAsync thrpt 3 12795.284 ± 2677.436 ops/s
FileAppenderThrowableBenchmark.complexLogbackFile thrpt 3 11377.932 ± 25787.767 ops/s
FileAppenderThrowableBenchmark.julFile thrpt 3 54271.234 ± 42052.793 ops/s
FileAppenderThrowableBenchmark.log4j1 thrpt 3 75694.883 ± 13310.643 ops/s
FileAppenderThrowableBenchmark.log4j2ExtendedThrowable thrpt 3 46216.007 ± 1046.523 ops/s
FileAppenderThrowableBenchmark.log4j2Throwable thrpt 3 110604.119 ± 33981.960 ops/s
FileAppenderThrowableBenchmark.logbackFile thrpt 3 112429.311 ± 95759.913 ops/s
----
---
[GitHub] logging-log4j2 issue #210: [LOG4J2-2391] Lazily initialize ThrowableProxy da...
Posted by cakofony <gi...@git.apache.org>.
Github user cakofony commented on the issue:
https://github.com/apache/logging-log4j2/pull/210
@rgoers Absolutely, this is not ready to merge.
@garydgregory The idea is that loading classes in order to add extended stack trace information can be incredibly expensive depending on the application. On java 8 using the default ClassLoader (network classloaders may be much slower), the benchmarks show a performance drop from 13,000 ops/s to 2,500 ops/s depending on whether we use the throwable pattern, or extended throwable pattern, which uses a ThrowableProxy. For synchronous logging, we can simply select the `%ex` pattern instead of `%xEx` (default) and avoid initializing a ThrowableProxy instance, avoiding class loading.
Upon further inspection, AsyncLoggerContextSelector (unlike AsyncLoggerConfig) does not initialize ThrowableProxy until it is is requested, which always occurs on the background thread. This is broken in a slightly different way. The performance is ideal because it avoids creating a stack trace as well as class loading, however when class loading is required, the context classloader from where the throwable was logged has already been lost, and the stack trace only contains frames from the disruptor background thread rather than those from the stack where the exception was caught and logged.
---
[GitHub] logging-log4j2 issue #210: [LOG4J2-2391] Lazily initialize ThrowableProxy da...
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:
https://github.com/apache/logging-log4j2/pull/210
Clearly we should fix bugs. It seems normal that using layout patterns that query for more data will be slower... Maybe that fact should be better documented in the pattern layout: Displaying extended stack traces is slower than normal stack traces... for those who care... ;-)
---
[GitHub] logging-log4j2 issue #210: [LOG4J2-2391] Lazily initialize ThrowableProxy da...
Posted by rgoers <gi...@git.apache.org>.
Github user rgoers commented on the issue:
https://github.com/apache/logging-log4j2/pull/210
As I said on the mailing list, I would like to simplify ThrowableProxy by moving all the rendering logic to a new Class, ThrowableProxyRenderer. I don't know how it got this way but somewhere along the line we have over-complicated this class to the point that it is hard to figure out what it is doing.
---
[GitHub] logging-log4j2 issue #210: [LOG4J2-2391] Lazily initialize ThrowableProxy da...
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:
https://github.com/apache/logging-log4j2/pull/210
Is this level of complication really worth it? Can you translate you findings in plain English SVP?
---
[GitHub] logging-log4j2 issue #210: [LOG4J2-2391] Lazily initialize ThrowableProxy da...
Posted by rgoers <gi...@git.apache.org>.
Github user rgoers commented on the issue:
https://github.com/apache/logging-log4j2/pull/210
Yes, the performance is important when it clearing is underperforming.
---