-
Notifications
You must be signed in to change notification settings - Fork 1k
Optimize Tag Handling in DefaultMeterObservationHandler #6035
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
HYEONSEOK1
wants to merge
1
commit into
micrometer-metrics:main
Choose a base branch
from
HYEONSEOK1:cache-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
fe276cf
to
429f5c6
Compare
Thanks for the pull request. I'll take a closer look later, but having JMH benchmarks would help quantify and demonstrate the difference this makes. |
Signed-off-by: HYEONSEOK1 <[email protected]>
@shakuzen I've added JMH benchmarks to quantify the performance difference before and after the optimizations. Below is a comparison of the results: Benchmark Results Click to view benchmark results Threads(4)Benchmark ResultsBaseline
Observation
Observation With optimisations (40f6268)
Observation Without Thread Contention
Observation Without Thread Contention With optimisations (40f6268)
Click to view benchmark results Threads(30)Benchmark ResultsBaseline
Observation
Observation With optimisations (40f6268)
Observation Without Thread Contention
Observation Without Thread Contention With optimisations (40f6268)
|
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.
Optimize Tag Handling in DefaultMeterObservationHandler
Summary
This PR optimizes tag handling in
DefaultMeterObservationHandler
by introducing a caching mechanism usingConcurrentHashMap
.It addresses micrometer-metrics/micrometer#6031, which reports performance degradation due to unnecessary tag sorting.
Changes Introduced
🔹 Tag Caching Mechanism
ConcurrentHashMap<Map.Entry<String, KeyValues>, Tags>
to cache computedTags
instances.🔹 Optimized
getOrCreateTags
MethodTags
from the cache when available.Tags
only if not already stored.🔹 Ensured Ordering with
KeyValues
KeyValues
is aSortedSet
, maintaining natural ordering.Let me know if any refinements are needed! 🚀