apache / logging-log4cxx

Apache Log4cxx is a C++ port of Apache Log4j
http://logging.apache.org/log4cxx
Apache License 2.0
278 stars 122 forks source link

Improve async appender performance #360

Closed swebb2066 closed 8 months ago

swebb2066 commented 8 months ago

This PR changes AsyncAppender implementation to use a preallocated ring buffer and is inspired by LMAX Disruptor

The benchmark comparison to master ( benchmark/tools/compare.py --no-color benchmarks /tmp/old.json /tmp/new.json ) shows the following improvement on Ubuntu (gcc 9):

Benchmark Time CPU Time Old Time New CPU Old CPU New
Appending int+float using MessageBuffer, pattern: %m%n -0.0288 -0.0289 966 938 966 938
Appending int+float using MessageBuffer, pattern: %m%n/threads:4 +0.0164 +0.0157 425 432 1698 1725
Appending int+float using FMT, pattern: %m%n -0.0621 -0.0621 543 509 543 509
Appending int+float using FMT, pattern: %m%n/threads:4 +0.0034 +0.0039 380 381 1511 1517
Async, Sending int+float using MessageBuffer -0.316 -0.3159 2171 1485 2171 1486
Async, Sending int+float using MessageBuffer/threads:4 -0.527 -0.4956 847 400 3175 1601