Performance: Avoid allocation if log level > finer#563
Open
sghill wants to merge 1 commit into
Open
Conversation
jtnord
reviewed
May 29, 2026
jtnord
reviewed
May 29, 2026
6 tasks
5da10a1 to
a6b9d4d
Compare
jtnord
approved these changes
Jun 1, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR stops allocating
Supplierobjects in a hot path ifLevel.FINERis not loggable.I've been having some performance issues with Jenkins controllers as the queue size and incoming agent connections grow, similar to what's described in #560.
I profiled with JFR's
settings=profileconfiguration, and found 20% of samples over a few hours were inLOGGER.finer(Supplier)in this code path. I know sampling isn't perfect and there are more impactful changes described in 560, but I thought this may be a nice first contribution to this plugin - it is a hot path that is allocating aSupplieron every iteration of the loop. For anyone who has the root logger set toINFO, it'd be better to avoid that allocation since it won't be logged anyway.Testing done
mvn clean verifyand JMH Benchmarks that include theorg.apache.logging.log4j:log4j-julbridge I'm using in production. I ran my benchmarks on a Macbook Pro M1 Max with 2 forks, 5 warmup iterations and 10 benchmark iterations.It showed an improvement of 13% with a queue size of 2000:
Submitter checklist