Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1693

log4j2: performance impact

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • 3.4
    • None
    • None

      I'm seeing sub-par performance with the program below, and thought maybe some of the bright folks on this list could help...

      The issue I'm having is that the new logging format log.trace("some string %s", string) is much slower than the old one if(log.isTraceEnabled()) log.trace("some string " + string).

      This is the case both with TRACE logging enabled and disabled !

      The logger here is basically a pass-through to log4j2.

      The test can be started with
      java org.jgroups.tests.bla5 10000 true // use the new format
      or
      java org.jgroups.tests.bla5 10000 false / use the old format

      Tracing disabled (org.jgroups.tests.bla5 = "warn"), 100000 iterations

      • OLD :5.0 M statements/sec
      • NEW: 2.7 M statements/sec

      Questions / observations:

      • If I uncomment the log.isTraceEnabled() in NEW, I get the same perf (5 M) as with OLD, makes sense
      • If I remove the varargs, I get the same perf, too
      • Q: is it the creation of the vararg array and the copying of the args into it which takes so much time ?

      Tracing enabled (org.jgroups.tests.bla5 = "trace"), 5000 iterations (prints to stdout)

      • OLD: 11'000 statements / sec
      • NEW: 7'200 statements / sec

      Questions/observations:

      • If I don't pass the varargs, e.g. log.trace("static string"), the perf in NEW is 12'000 !
      • Q: is the parsing of the format string taking that much time, such that it is slower than the conversion of i into a string and the string concatenation/copying in the OLD version ?

      Some discussion on the core dwelt on the merits of using OLD versus NEW, and my take-away was that NEW was as fast as OLD. Is this not te case ?

        1. log4j2.xml
          0.5 kB
        2. bla5.java
          1 kB

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: