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
- relates to
-
LOG4J2-1270 Garbage-free steady-state logging
- Open
-
LOG4J2-3472 Allow configuration of custom Disruptor WaitStrategy
- Closed
-
LOG4J2-574 Make Blocking the default WaitStrategy for Async Loggers
- Closed
- links to