Skip to content
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

Improve performance of merging two Tags/KeyValues instances #5140

Closed
mstyura opened this issue May 23, 2024 · 1 comment
Closed

Improve performance of merging two Tags/KeyValues instances #5140

mstyura opened this issue May 23, 2024 · 1 comment
Assignees
Labels
enhancement A general enhancement module: micrometer-core An issue that is related to our core module performance Issues related to general performance
Milestone

Comments

@mstyura
Copy link
Contributor

mstyura commented May 23, 2024

Please describe the feature request.
This is enhancement request to speed up common operations on set of Tags. Depending on scenario application may use some of the operations on tags very often causing micrometer to be non-negligible consumer of CPU of service relying on it.
The following operations are proposed to be optimised:

  1. Initialisation of Tags from already sorted array of unique tags;
  2. Merging two Tags objects in optimal way taking into account that tags are stored as sorted arrays.

Rationale
I've observed unexpectedly high CPU time spent in micrometer library in several production services I have access to. Here is screenshots from DataDog profiler:
image
with most of the time is actually spent on two things: creating Tags object and merging two Tags objects:
image

Additional context
I've already did initial PR #4959 which seems to be already lost among many of bot-generated PRs. So I've decided to created dedicated issue to keep track of progress towards making optimisations on Tags happen and be accepted.

@mstyura
Copy link
Contributor Author

mstyura commented Oct 1, 2024

@jonatan-ivanov may I ask you to have a look at the linked MR with proposed tags merge optimizations? Thanks a lot in advance!

@shakuzen shakuzen added enhancement A general enhancement performance Issues related to general performance module: micrometer-core An issue that is related to our core module labels Oct 2, 2024
@shakuzen shakuzen changed the title Speedup operations on Tags. Improve performance of merging two Tags/KeyValues instances Oct 3, 2024
@shakuzen shakuzen added this to the 1.14.0-RC1 milestone Oct 3, 2024
shakuzen pushed a commit that referenced this issue Oct 3, 2024
Improves the performance of merging two Tags instances by taking advantage of the fact that their internal representation of tags is always sorted and deduplicated. Therefore, they can be merged more efficiently than a collection of tags that may not be sorted and deduplicated.
Added benchmark to measure Tags.and(Tags) operation.

See gh-5140
@shakuzen shakuzen self-assigned this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement module: micrometer-core An issue that is related to our core module performance Issues related to general performance
Projects
None yet
Development

No branches or pull requests

3 participants