tinylog-org / tinylog

tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android
https://tinylog.org
Apache License 2.0
696 stars 82 forks source link

Non-blocking writerThread implementation #88

Closed re-thc closed 5 years ago

re-thc commented 5 years ago

Hi, most of log4j2's async performance comes from https://lmax-exchange.github.io/disruptor/. Has this been considered for the writerThread implementation? It currently uses mutex / synchronization. Maybe a similar route would just be using a non blocking queue e.g. disruptor or similar from JCTools.

Thanks!

pmwmedia commented 5 years ago

When I started developing tinylog 2, I created three different writing thread implementations. One of them was based on LMAX Disruptor. Based on benchmarks, I chose the current writing thread implementation, because it could output slightly more log entries per second than the LMAX Disruptor based implementation.

If anyone can implement a writing thread implementation that can output more log entries per second than the current implementation (proven by benchmarks), I would be pleased to integrate it into tinylog.

re-thc commented 5 years ago

Thanks. Curious to know what was the currency settings at the time (i.e. use case). Was like a webserver with many threads that would log, e.g. in a HTTP server? Definitely the mutex/current approach would be better when there's less contention. What settings did you pick for blocking strategy? LMAX does generate quite a bit of garbage. More simply using just a non-blocking queue might be better.

pmwmedia commented 5 years ago

I have benchmarked the number of log entries that can be processed per second. Performance is always a critical question. Often, bottlenecks are not where expected and some optimizations can make it worse, even if they look promising. Therefor, the best way is writing a benchmark for a component to verify, if it is really slow, and benchmarking possible replacements.

For tinylog 2, I have developed three different writing thread implementations and run the benchmark https://tinylog.org/v2/benchmark/ for all of them.

github-actions[bot] commented 1 year ago

This closed issue has been locked automatically. However, please feel free to file a new issue.