Skip to content

Conversation

hailshao
Copy link

…rowableProxyHelperbak#loadClass

1、log4j2.component.properties
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
2、for (int i = 0; i < 600000; i++) {
logger.error("aa", aa);
}
3、iotop(linux)only 13M/s
stuck on ThrowableProxyHelper#loadClass
4、 iotop(linux)new way:140M/s

Copy link

github-actions bot commented Oct 16, 2024

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

@vy
Copy link
Member

vy commented Oct 16, 2024

@hailshao, thanks for your contribution. Would you mind helping with the following questions, please?

  1. Which version of Log4j Core are you using?
  2. Could you share your log4j2.xml, please?
  3. Exception rendering has been rewritten since the last release. Could you see if the most recent 2.25.0-SNAPSHOT is also problematic, please? (Or just build locally from the 2.x tip.)
  4. Is it possible for you to switch from %xEx to %ex? (Collecting extended stack trace information is slow, has always been problematic, in particular, while in an async. context, and %ex is just fine in almost all use cases.)

@hailshao
Copy link
Author

1、Which version of Log4j Core are you using?
answer:
force 'org.apache.logging.log4j:log4j-slf4j-impl:2.24.1'
force 'org.apache.logging.log4j:log4j-core:2.24.1'
force 'org.apache.logging.log4j:log4j-api:2.24.1'
force 'org.apache.logging.log4j:log4j-jul:2.24.1'

2、Could you share your log4j2.xml, please?
answer:The file has been uploaded

3、Exception rendering has been rewritten since the last release. Could you see if the most recent 2.25.0-SNAPSHOT is also problematic, please? (Or just build locally from the 2.x tip.)
answer:I will try later

4、Is it possible for you to switch from %xEx to %ex? (Collecting extended stack trace information is slow, has always been problematic, in particular, while in an async. context, and %ex is just fine in almost all use cases.)
answer:I will try later

log4j.zip

@ppkarwasz
Copy link
Contributor

ppkarwasz commented Oct 17, 2024

#队列满时放弃日志操作
log4j2.AsyncQueueFullPolicy=Discard
#队列满时放弃级别小于等于指定级别的日志,默认值INFO
log4j2.DiscardThreshold=INFO
#开启日志全异步。System.setProperty或者启动参数方式生效场景有:开发环境和jar包方式启动,而tomcat环境却不生效
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
#当队列满时同步入列,这是默认值,实际还是走AsyncQueueFullPolicy策略
#AsyncLoggerConfig.SynchronizeEnqueueWhenQueueFull=true
#队列长度,Disruptor使用的不是真正意义上的队列,而是类似于计数器+事件的方式。
#AsyncLoggerConfig.RingBufferSize=131072

This is unrelated to your problem, but I wanted to give you the heads up that we changed the official names of the properties you are using in version 2.10 to log4j2.asyncQueueFullPolicy, log4j2.discardThreshold, log4j2.contextSelector, log4j2.asyncLoggerSynchronizeEnqueueWhenQueueFull and log4j2.asyncLoggerRingBufferSize. The old property names are supported for backward compatibility, but support for them will be dropped in 3.0.0.

@hailshao
Copy link
Author

1、jar
a) 2.24.1 (gradle download)
force 'org.apache.logging.log4j:log4j-slf4j-impl:2.24.1'
force 'org.apache.logging.log4j:log4j-core:2.24.1'
force 'org.apache.logging.log4j:log4j-api:2.24.1'
force 'org.apache.logging.log4j:log4j-jul:2.24.1'

b) 2.25.0-SNAPSHOT(manual download):
https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/log4j-core/2.25.0-SNAPSHOT/log4j-core-2.25.0-20241016.104251-51.jar
https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/log4j-api/2.25.0-SNAPSHOT/log4j-api-2.25.0-20241016.104251-51.jar
https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/log4j-jul/2.25.0-SNAPSHOT/log4j-jul-2.25.0-20241016.104251-51.jar
https://repository.apache.org/content/groups/snapshots/org/apache/logging/log4j/log4j-slf4j-impl/2.25.0-SNAPSHOT/log4j-slf4j-impl-2.25.0-20241016.104251-51.jar

2、DISK WRITE
a) speed1(slow)
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.24.1
iotop: 13M/s

b) speed2(slower)
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.25.0-SNAPSHOT
or
log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.25.0-SNAPSHOT
iotop: 4.5M/s

c) speed3(fast)
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.24.1 + %ex
iotop: 110M/s

3、result
Thank you very much, we have accepted your proposal: switch %xEx to% ex.

Please refer to the attachment for details
speed.zip

@ppkarwasz
Copy link
Contributor

2、DISK WRITE a) speed1(slow) Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.24.1 iotop: 13M/s

b) speed2(slower) Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.25.0-SNAPSHOT or log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector + 2.25.0-SNAPSHOT iotop: 4.5M/s

Thanks for the heads up. I have opened #3106 to check the cause of the performance loss you have reported and I am closing this PR, since I suppose it is no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants