Optimize Tag Handling in DefaultMeterObservationHandler - #6035
Open
HYEONSEOK1 wants to merge 1 commit into
Open
HYEONSEOK1 wants to merge 1 commit into
HYEONSEOK1 wants to merge 1 commit into
Conversation
HYEONSEOK1
force-pushed
the
cache-tags
branch
3 times, most recently
from
March 17, 2025 15:32
fe276cf to
429f5c6
Compare
Member
|
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 <gustir929@gmail.com>
Contributor
Author
|
@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)
|
This branch has not been deployed
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.
Optimize Tag Handling in DefaultMeterObservationHandler
Summary
This PR optimizes tag handling in
DefaultMeterObservationHandlerby 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 computedTagsinstances.🔹 Optimized
getOrCreateTagsMethodTagsfrom the cache when available.Tagsonly if not already stored.🔹 Ensured Ordering with
KeyValuesKeyValuesis aSortedSet, maintaining natural ordering.Let me know if any refinements are needed! 🚀