carterkozak commented on pull request #485:
URL: https://github.com/apache/logging-log4j2/pull/485#issuecomment-817314934


   Our fully async disruptor implementation is indeed very difficult to beat in 
benchmarks, largely for the reasons you've mentioned, also due to the tighter 
control of the threading model we get by integrating it directly into the 
logger system (See AsyncLoggerContext, AsyncLogger) rather than applying it to 
individual appenders (which requires defensive copies of LogEvent objects). 
This makes it more difficult to like-for-like compare a jctools implementation 
to the disruptor implementation.
   
   > 1. FIFO (I suppose that's mandatory right? If we just need FIFO for the 
same thread, there are much faster options on JCTools ala 
https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/MpscCompoundQueue.java#L136
   ie using a fixed size of queues to distribute contention on the tail)
   
   Mandatory? That's difficult to say. In the general case I'd say so, however 
many services push events into complex logging pipelines which handle event 
ordering based on timestamps or some other identifier, so it doesn't matter so 
much what order events are produced in (depending on the system, of course!)
   
   > 2. Object pool: this is unbeatable
   
   Agreed, this is a big one for us.
   
   > 3. batch-friendly: no idea how much this feature is used on log4j, but it 
can be rather important while appending files to batch writes syscalls (on 
FileChannel pwrite).
   
   The default configuration doesn't take advantage of this property, however 
configuring most appenders `immediateFlush` property allows them to wait until 
a LogEvent with `endOfBatch=true` before flushing, in my experience this 
increases logging throughput by an order of magnitude.
   
   This reminds me, I had meant to research the feasibility of something like 
libaio for logging file i/o, I recall that you may have some experience with 
the java bindings? ;-) I imagine eventually io_uring may allow us to batch 
appends to multiple files into a single syscall, this could be huge as it's 
common to have some subset of events recorded to multiple files, but I 
admittedly haven't read as much about how this works in practice as I should.
   
   >  I still see a value in using an unbounded q especially if compared with 
policies that would change the logs order or block the application threads.
   
   Thar be dragons! It would be remarkably easy to OOM with an unbounded queue 
if used incorrectly -- in production systems it's often safer to increase the 
ringbuffer size and use a discarding policy when the queue is filled, but I 
don't mind allowing the option for an unbounded queue (on AsyncAppender one can 
already configure a LinkedBlockingQueue with Integer.MAX_VALUE capacity!). I do 
like the idea of a queue with a dynamic footprint, at work I use a large 
constant size ringbuffer which accounts for a large chunk of system memory 
utilization regardless of load or expectations for the service.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to