• Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: Layouts, Pattern Converters
    • Labels:


      In addition to the work done for LOG4J2-812 (replace synchronized SimpleDateFormat with commons FastDateFormat) I see a way to improve performance for the timestamp even further.

      Ralph posted some very nice JMH benchmark results in LOG4J2-812, where the combination of caching, FastDateFormat and an AtomicReference was the winner.

      I believe this is the way to go, but we may be able to do even better. For some common date formats, it is possible to get a 5X speedup versus FastDateFormat.

      This is not as generic as FastDateFormat; at the moment it only supports HH:mm:ss,SSS. I would like to support the "common" DatePatternConverter formats ABSOLUTE, COMPACT, DATE_AND_TIME, DEFAULT, ISO8601_BASIC and ISO8601. For any other date format pattern we fall back to FastDateFormat.

      Performance results are below (benchmark is in git master):

      Benchmark                                                          Mode  Samples    Score    Error  Units
      o.a.l.l.p.j.TimeFormatBenchmark.baseline                         sample   118021   18.783 ±  0.842  ns/op
      o.a.l.l.p.j.TimeFormatBenchmark.customBitFiddlingFormatString    sample   157268   87.616 ±  1.557  ns/op
      o.a.l.l.p.j.TimeFormatBenchmark.customFormatString               sample   170168   82.650 ±  1.326  ns/op
      o.a.l.l.p.j.TimeFormatBenchmark.customFormatStringBuilder        sample   108884   67.825 ±  1.577  ns/op
      o.a.l.l.p.j.TimeFormatBenchmark.fastDateFormatString             sample   148478  317.145 ±  1.850  ns/op
      o.a.l.l.p.j.TimeFormatBenchmark.simpleDateFormatString           sample   173226  263.886 ± 10.615  ns/op


          Issue Links



              • Assignee:
                rpopma Remko Popma
                rpopma Remko Popma
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: