-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
High CPU usage in async mode with Log4j2 #3635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
com.lmax.disruptor.SleepingWaitStrategy#applyWaitMethod |
Depending on the Disruptor waiting strategy you choose a high CPU usage on the asynchronous thread is perfectly normal. See the documentation of the You can finely tune the
Does this solve your problem? |
I know this configuration can avoid this problem, but the question is whether there is a problem with this default configuration and whether it needs to be adjusted. |
I don't feel competent to answer to that. However, the value we use in Log4j Core are exactly the same values used by the LMAX Disruptor library: private static final int DEFAULT_RETRIES = 200;
private static final long DEFAULT_SLEEP = 100; I wouldn't feel comfortable modifying those values without extensive benchmarks and usage statistics. Values that are perfect for your use case might match the expectations of most Log4j Core or might be the exception. It is impossible to say. You can try proposing a change in the LMAX Disruptor library directly. If they change the defaults, we will follow their recommendations. |
Description
When using Log4j2 in asynchronous logging mode, the CPU usage is significantly higher than expected, even under low logging throughput. This issue persists regardless of the configured
Configuration
Version: [2.24.3]
Operating system: [linux 6.8]
JDK: [jdk 11]
Logs
Reproduction
[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
-DAsyncLogger.WaitStrategy=Sleep
add these jvm options
and run ,we will found the high cpu usage on "Log4j2-TF" thread
The text was updated successfully, but these errors were encountered: