You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "lucasbru (via GitHub)" <gi...@apache.org> on 2026/02/17 14:33:40 UTC

[PR] KAFKA-18046: Avoid repeated logger creation in InternalTopicManager [kafka]

lucasbru opened a new pull request, #21494:
URL: https://github.com/apache/kafka/pull/21494

   As reported in https://github.com/apache/kafka/pull/19138, `LoggerFactory.getLogger()` is expensive with log4j2. `InternalTopicManager.configureTopics` and the helper classes it instantiates (`RepartitionTopics`, `CopartitionedTopicsEnforcer`, `ChangelogTopics`) each called `logContext.logger()` on every invocation, creating 4 new loggers per call. Since `configureTopics` is called on the streams group heartbeat path, this adds unnecessary CPU overhead.
   
   This changes all four classes to accept a pre-created `Logger` instead of a `LogContext`, so that the caller's existing logger is reused rather than creating new loggers on every `configureTopics` call.
   
   A simple microbenchmark shows that with log4j2, `logContext.logger()` costs ~4 microseconds per call (~10 microseconds for the 4 loggers created per `configureTopics` invocation), compared to ~0.14 microseconds with the NOP logger.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Avoid repeated logger creation in InternalTopicManager [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru merged PR #21494:
URL: https://github.com/apache/kafka/pull/21494


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org