[ 
https://issues.apache.org/jira/browse/KAFKA-19470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18101162#comment-18101162
 ] 

Yunseop Eom commented on KAFKA-19470:
-------------------------------------

PR opened: https://github.com/apache/kafka/pull/23044 for KAFKA-19470. Added a 
thread-safe logger-name cache so immutable Scala logger wrappers are reused 
across Logging instances while preserving loggerName overrides. Added a 
regression test; core LoggingTest, Spotless, Checkstyle, and SpotBugs passed. 
Status: PR open and awaiting review.

> Avoid creating loggers repeatedly to affect the performance of request 
> processing
> ---------------------------------------------------------------------------------
>
>                 Key: KAFKA-19470
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19470
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 2.8.2
>            Reporter: terrytlu
>            Priority: Major
>         Attachments: 20250704-145553.html, image-2025-07-04-19-05-51-900.png, 
> image-2025-07-04-19-25-57-774.png
>
>
> We see that the broker has a performance bottleneck when processing requests 
> in kafka 2.8.2 version + jdk 11 environment. The CPU profiler is as follows:
> !image-2025-07-04-19-05-51-900.png|width=1065,height=489!
> After research, we found that this is a problem with jdk11 but without 
> resolution [https://bugs.openjdk.org/browse/JDK-8266964]  StackWalker has a 
> performance degradation for jdk11.
> When creating every logger, log4j2 will invoke StackWalker, the following is 
> the performance data observed with arthas. It takes about 60ms to create each 
> logger.
> !image-2025-07-04-19-25-57-774.png|width=725,height=367!
> we should set the logger variable of each class to static to avoid wasting 
> performance on creating loggers.
> seen in KAFKA-15141, the corresponding classes 
> IncrementalFetchContext/DelayedProduce/SessionlessFetchContext have been 
> processed, but I think a better approach should be to optimize the trait 
> Logging, to avoid similar performance issues later. We can introduce a static 
> Map object to cache the duplicate loggers.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to