Consider to remove sorting at MeterIdPrefix #2150
Comments
|
We can make use of the following characteristics:
|
|
I don't think this would be an issue if we sorted during metric export instead of when recording metrics. Do you think it's possible to move sorting to a different layer that only occurs during export? |
|
That's a good point. We could:
|
|
I played with this a little and found
Also of the optimizations in I guess the one that might have an affect is doing insertion sort for merging - Let me now if you have any thoughts. |
|
By the way, @imasahiro are you using default |
|
@anuraaga Yes, basically, I'm using armeria-spring's default |
|
Wouldn't order-indepdendent |
|
The benchmark in my PR does the prefix generation+register but I didn't see it cover the difference unfortunately. I guess it would require very slow sorting (adding largish number of tags in very random order) to see the difference so maybe we can live with it now since default function can be made to add the tags in order. |
This is the smallest solution for helping with the performance of tag addition. Our default logic can at least add tags in order to prevent reordering when sorting (TimSort handles already-sorted arrays well without special logic). Also removes comparator when sorting since `Tag` is `Comparable` and adds tests for `Equals/HashCode` for use in playing with those functions. For #2150 After ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 6816146.723 ▒ 1548641.211 ops/s ``` Before ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 5813367.536 ▒ 154548.384 ops/s ```
This is the smallest solution for helping with the performance of tag addition. Our default logic can at least add tags in order to prevent reordering when sorting (TimSort handles already-sorted arrays well without special logic). Also removes comparator when sorting since `Tag` is `Comparable` and adds tests for `Equals/HashCode` for use in playing with those functions. For line#2150 After ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 6816146.723 ▒ 1548641.211 ops/s ``` Before ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 5813367.536 ▒ 154548.384 ops/s ```
This is the smallest solution for helping with the performance of tag addition. Our default logic can at least add tags in order to prevent reordering when sorting (TimSort handles already-sorted arrays well without special logic). Also removes comparator when sorting since `Tag` is `Comparable` and adds tests for `Equals/HashCode` for use in playing with those functions. For line#2150 After ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 6816146.723 ▒ 1548641.211 ops/s ``` Before ``` Benchmark Mode Cnt Score Error Units RequestMetricSupportBenchmark.registerSameTags thrpt 5 5813367.536 ▒ 154548.384 ops/s ```

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Currently, we sort the micrometer tags at MeterIdPrefix to create Meter ID stably.
https://github.com/line/armeria/blob/master/core/src/main/java/com/linecorp/armeria/common/metric/MeterIdPrefix.java#L95-L101
Since I saw this stacktrace from our service’s flamegraph, I would like to consider whether it is avoidable or not. Since it doesn’t have many samples, we can be ignored but because it is not optimal, it would be happy if we can avoid this sort.
The text was updated successfully, but these errors were encountered: