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

[metrics.Map] Use generics to implement Map #444

Merged
merged 13 commits into from
Aug 8, 2023
Merged

[metrics.Map] Use generics to implement Map #444

merged 13 commits into from
Aug 8, 2023

Conversation

manugarg
Copy link
Contributor

@manugarg manugarg commented Aug 6, 2023

No description provided.

Map implementation is complex and expensive primarily to deal with both
int64 and float64 values. Map is used almost always as a counter (e.g.
resp-code, validation failure map), except for external probe output
parsing where we can encounter a float map.

To simplify Map implementation, split it into two implementations: Map
(for int64 counters) and MapFloat (for any float64 values map).
… cloning performance.

* Improve cloning performance by 33% by pre-allocating the map:
- BenchmarkMapClone   908  1207415 ns/op  2053905 B/op  6413 allocs/op
+ BenchmarkMapClone  1305   840008 ns/op  1375780 B/op  4152 allocs/op
@manugarg manugarg merged commit 68eab8a into master Aug 8, 2023
9 of 10 checks passed
@manugarg manugarg deleted the map_generic branch August 8, 2023 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant