Remko Popma created LOG4J2-3473:
-----------------------------------

             Summary: Provide garbage-free default disruptor WaitStrategy
                 Key: LOG4J2-3473
                 URL: https://issues.apache.org/jira/browse/LOG4J2-3473
             Project: Log4j 2
          Issue Type: New Feature
          Components: Core
    Affects Versions: 2.17.2
            Reporter: Remko Popma
            Assignee: Remko Popma
             Fix For: 2.17.3


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|https://github.com/LMAX-Exchange/disruptor/issues/227], 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.)

h4. 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|https://github.com/LMAX-Exchange/disruptor/blob/master/src/main/java/com/lmax/disruptor/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 message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to