[ 
https://issues.apache.org/jira/browse/LOG4J2-2644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16880031#comment-16880031
 ] 

Ralph Goers commented on LOG4J2-2644:
-------------------------------------

Performance results comparing before any changes and after all changes.
{code:java}
Release 2.x Before Changes   4 Threads

Benchmark                                    Mode  Cnt        Score       Error 
 Units
FileAppenderBenchmark.julFile               thrpt   20    30536.101 ¬±   
858.591  ops/s
FileAppenderBenchmark.log4j1File            thrpt   20   617306.350 ¬± 
16010.513  ops/s
FileAppenderBenchmark.log4j2AsyncAppender   thrpt   20   435017.227 ¬± 
17070.693  ops/s
FileAppenderBenchmark.log4j2AsyncDisruptor  thrpt   20   959897.397 ¬± 
28078.800  ops/s
FileAppenderBenchmark.log4j2AsyncLogger     thrpt   20  1129097.193 ¬± 
38648.100  ops/s
FileAppenderBenchmark.log4j2File            thrpt   20  1041400.912 ¬± 
32562.135  ops/s
FileAppenderBenchmark.log4j2RAF             thrpt   20  1112014.290 ¬± 
22171.312  ops/s
FileAppenderBenchmark.logbackAsyncFile      thrpt   20   468825.311 ¬± 
20857.864  ops/s
FileAppenderBenchmark.logbackFile           thrpt   20   978704.022 ¬± 
23239.574  ops/s

Benchmark                                       Mode  Cnt       Score      
Error  Units
FileAppenderWithLocationBenchmark.log4j1File   thrpt   20   49509.572 ¬± 
6261.952  ops/s
FileAppenderWithLocationBenchmark.log4j2File   thrpt   20  156442.483 ¬± 
6253.948  ops/s
FileAppenderWithLocationBenchmark.log4j2RAF    thrpt   20  145652.582 ¬± 
7432.223  ops/s
FileAppenderWithLocationBenchmark.logbackFile  thrpt   20  144273.461 ¬± 
6404.892  ops/s   

Release 2.x After Changes     4 Threads

Benchmark                                    Mode  Cnt        Score       Error 
 Units
FileAppenderBenchmark.julFile               thrpt   20    42467.810 ¬±  
1769.847  ops/s
FileAppenderBenchmark.log4j1File            thrpt   20   635168.969 ¬± 
18965.265  ops/s
FileAppenderBenchmark.log4j2AsyncAppender   thrpt   20   450376.886 ¬± 
25937.515  ops/s
FileAppenderBenchmark.log4j2AsyncDisruptor  thrpt   20  1012156.176 ¬± 
23415.378  ops/s
FileAppenderBenchmark.log4j2AsyncLogger     thrpt   20  1259536.386 ¬± 
31958.779  ops/s
FileAppenderBenchmark.log4j2File            thrpt   20  1166042.327 ¬± 
24917.504  ops/s
FileAppenderBenchmark.log4j2RAF             thrpt   20  1205182.808 ¬± 
32388.393  ops/s
FileAppenderBenchmark.logbackAsyncFile      thrpt   20   533475.105 ¬± 
12298.555  ops/s
FileAppenderBenchmark.logbackFile           thrpt   20  1180302.637 ¬± 
16191.367  ops/s

Benchmark                                       Mode  Cnt       Score      
Error  Units
FileAppenderWithLocationBenchmark.log4j1File   thrpt   20   55333.318 ¬± 
1056.748  ops/s
FileAppenderWithLocationBenchmark.log4j2File   thrpt   20  193114.226 ¬± 
3694.770  ops/s
FileAppenderWithLocationBenchmark.log4j2RAF    thrpt   20  210400.326 ¬± 
3427.059  ops/s
FileAppenderWithLocationBenchmark.logbackFile  thrpt   20  129510.641 ¬± 
2934.328  ops/s

Release 3.x Before Changes    4 Threads

Benchmark                                    Mode  Cnt       Score       Error  
Units
FileAppenderBenchmark.julFile               thrpt   20   30124.191 ¬±  5789.724 
 ops/s
FileAppenderBenchmark.log4j1File            thrpt   20  376516.283 ¬± 27072.069 
 ops/s
FileAppenderBenchmark.log4j2AsyncAppender   thrpt   20  294996.863 ¬± 15507.474 
 ops/s
FileAppenderBenchmark.log4j2AsyncDisruptor  thrpt   20  573890.697 ¬± 26375.565 
 ops/s
FileAppenderBenchmark.log4j2AsyncLogger     thrpt   20  520976.275 ¬± 27280.963 
 ops/s
FileAppenderBenchmark.log4j2File            thrpt   20  404600.346 ¬± 32764.188 
 ops/s
FileAppenderBenchmark.log4j2RAF             thrpt   20  588507.044 ¬± 15255.207 
 ops/s
FileAppenderBenchmark.logbackAsyncFile      thrpt   20  245658.860 ¬± 10594.429 
 ops/s
FileAppenderBenchmark.logbackFile           thrpt   20  506914.909 ¬±  6268.274 
 ops/s

Benchmark                                       Mode  Cnt       Score      
Error  Units
FileAppenderWithLocationBenchmark.log4j1File   thrpt   20   47113.312 ¬±  
604.509  ops/s
FileAppenderWithLocationBenchmark.log4j2File   thrpt   20  128269.166 ¬± 
3856.169  ops/s
FileAppenderWithLocationBenchmark.log4j2RAF    thrpt   20  128673.823 ¬± 
2625.317  ops/s
FileAppenderWithLocationBenchmark.logbackFile  thrpt   20  123472.627 ¬± 
2211.028  ops/s

Release 3.x After Changes     4 Threads

Benchmark                                    Mode  Cnt        Score       Error 
 Units
FileAppenderBenchmark.julFile               thrpt   20    33326.135 ¬±   
918.762  ops/s
FileAppenderBenchmark.log4j1File            thrpt   20   594480.764 ¬± 
15160.389  ops/s
FileAppenderBenchmark.log4j2AsyncAppender   thrpt   20   319499.481 ¬±  
5545.647  ops/s
FileAppenderBenchmark.log4j2AsyncDisruptor  thrpt   20   972707.271 ¬± 
33654.138  ops/s
FileAppenderBenchmark.log4j2AsyncLogger     thrpt   20  1038696.405 ¬± 
62221.518  ops/s
FileAppenderBenchmark.log4j2File            thrpt   20  1079429.488 ¬± 
28685.159  ops/s
FileAppenderBenchmark.log4j2RAF             thrpt   20  1113956.149 ¬± 
21609.459  ops/s
FileAppenderBenchmark.logbackAsyncFile      thrpt   20   438444.717 ¬±  
9520.599  ops/s
FileAppenderBenchmark.logbackFile           thrpt   20   984278.947 ¬± 
28560.305  ops/s

Benchmark                                            Mode  Cnt       Score      
 Error  Units
FileAppenderWithLocationBenchmark.log4j1File        thrpt   20   55437.605 ¬±  
1154.674  ops/s
FileAppenderWithLocationBenchmark.log4j2File        thrpt   20  176225.467 ¬±  
7695.072  ops/s
FileAppenderWithLocationBenchmark.log4j2FluentFile  thrpt   20  507453.923 ¬± 
12238.743  ops/s
FileAppenderWithLocationBenchmark.log4j2RAF         thrpt   20  166023.981 ¬±  
7193.730  ops/s
FileAppenderWithLocationBenchmark.logbackFile       thrpt   20  147522.065 ¬±  
3045.869  ops/s
 {code}

> Logging with location information is considerably slower than logging with 
> location information in java.util.logging
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2644
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2644
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.11.2
>            Reporter: Marco Herrn
>            Priority: Minor
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> according to https://logging.apache.org/log4j/2.x/performance.html logging
> with location information should be roughly the same performance for JUL
> and Log4j2.
> However I made a few comparisons between Log4j2 and JUL and in this case
> Log4j2 is much faster than JUL when omitting location information, but is
> considerably slower when logging with location information.
> Those are the results:
> JUL without location information   : 32.162s
> JUL with location information      : 21.682s
> Log4j2 without location information:  4.168s
> Log4j2 with location information   : 59.000s
> In each case I logged 1500000 simple log statements (only a fixed string)
> and compared the timestamp of the first and the last generated log
> statement. Above you see the time spent between the first and the last log
> statement.
> I did these tests several times and the results are equal each time.
> In all cases I logged to a RollingFileAppender (or JULs equivalent).
> I assume that JUL with location information is faster than JUL without
> location information is because for JUL with location information I used a
> custom Formatter that doesn't support any configuration whereas I was
> using a SimpleFormatter with a specified formatstring for JUL without log
> information.
> It should be noted that I didn't use the Log4j2 API, but instead used the
> JUL logging API and used the log4j-jul-bridge to actually use Log4j2
> instead of the JUL implementation!
> I want to pay special attention to the difference when logging with
> location information, since I am puzzled that Log4j2 is that much slower
> than JUL in that case.
> The example code used for testing and the corresponding logging 
> configurations can be found at [my example github 
> project|http://github.com/hupfdule/LoggingPerformanceTest].
> I don't think there is anything special. Since when logging without
> location information Log4j2 is much faster than JUL there must be a
> difference between getting the location information. My above mentioned
> custom formatter uses the methods java.util.LogRecord#getSourceClassName()
> and java.util.LogRecord#getSourceMethodName() for obtaining that
> information. I haven't looked into how Log4j2 does it, but it seems to be
> much less efficient.
> I have done the tests with Java 8, but it seems that running it under Java 11 
> shows the same behaviour.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to