Skip to content

KAFKA-19470 Avoid creating loggers repeatedly to affect the performance of request processing #20105

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

terrytlu
Copy link

@terrytlu terrytlu commented Jul 4, 2025

fix the issue mentioned https://issues.apache.org/jira/browse/KAFKA-19470, to avoid the jdk11 + lo4j2 performance issue.
Optimize the trait Logging, introduce a static Map object to cache the same class loggers.

The testing strategy is:
Create two instances, their classes inherit from the trait Logging, these two class instances will have the same variable logger, that is, the StackWalker method will not be called twice

@github-actions github-actions bot added triage PRs from the community core Kafka Broker small Small PRs labels Jul 4, 2025
@terrytlu
Copy link
Author

terrytlu commented Jul 4, 2025

hello @ijuma @divijvaidya , could please help review this pr 🙏

@gaurav-narula
Copy link
Contributor

Thanks for the PR! From the discussion in the previous PRs (#9910 (comment) and #13949 (comment)), one of the reasons to limit the change to frequently instantiated classes was an understanding that the Logging trait isn't a good-pattern.

Given there's a lot of refactoring in progress specially around the Scala code, should we instead look at moving away from the Logging trait?

@terrytlu
Copy link
Author

terrytlu commented Jul 8, 2025

Thanks for the PR! From the discussion in the previous PRs (#9910 (comment) and #13949 (comment)), one of the reasons to limit the change to frequently instantiated classes was an understanding that the Logging trait isn't a good-pattern.

Given there's a lot of refactoring in progress specially around the Scala code, should we instead look at moving away from the Logging trait?

Moving away from the Logging trait would require lots of work to refactor, every class that needs to log would need to create an object containing the logger. Not an easy proposal to implement I think... @gaurav-narula

Copy link

A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the triage label
should be removed to prevent this automation from happening again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker needs-attention small Small PRs triage PRs from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants