Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3473

Provide garbage-free default disruptor WaitStrategy

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.17.2
    • 2.18.0
    • Core
    • None

    Description

      The default disruptor WaitStrategy used for Async Logging (com.lmax.disruptor.TimeoutBlockingWaitStrategy) is not garbage-free, because its implementation uses a java.util.concurrent.locks.ReentrantLock, which internally allocates many AbstractQueuedSynchronizer$Node objects.

      This was fixed in https://github.com/LMAX-Exchange/disruptor/issues/227, where the ReentrantLock was replaced by a synchronized block, but this change is not included in the current production version 3.4.4 of LMAX Disruptor.

      (LMAX Disruptor 4.0.0.RC1 does include this fix, but that version of the Disruptor requires Java 11 (in addition to some other incompatible changes), so upgrading to Disruptor 4.0.0 will not be a solution for this ticket - at least not for Java 8 users.)

      Proposal:

      I propose to introduce a new class org.apache.logging.log4j.core.async.TimeoutBlockingWaitStrategy that is a copy of the latest version of the disruptor's TimeoutBlockingWaitStrategy.java.
      This would be the default WaitStrategy used by Log4j.

      The only different between this and the current default WaitStrategy is that the new implementation uses a synchronized block instead of a ReentrantLock, so no temporary objects are allocated, making this WaitStrategy garbage-free.

      This is the commit in the LMAX disruptor repo that has the change we are trying to introduce:
      https://github.com/LMAX-Exchange/disruptor/commit/a18f8198ab94590f0a5ec7c3378ba87f997ea670

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: