Repository navigation
Commit ee7af1e
committed
perf: skip snapshot rebuild in mergeDuplicates when names are unique
MetricSnapshots is always sorted by prometheus name, so duplicate names are
adjacent. Detect duplicates in a single allocation-free pass and, when there
are none (the common case), return the input unchanged instead of rebuilding
it through a LinkedHashMap, an ArrayList per group, a MetricSnapshots.Builder
and a freshly sorted MetricSnapshots.
The merge path for actual duplicates is unchanged. Output is byte-identical
(verified by the existing exposition-format tests, including
DuplicateNamesExpositionTest).
Signed-off-by: David Mollitor <david.mollitor@databricks.com>1 parent e43f451 commit ee7af1e
1 file changed
Lines changed: 18 additions & 0 deletions
File tree
- prometheus-metrics-exposition-textformats/src/main/java/io/prometheus/metrics/expositionformats
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
44 | 62 | | |
45 | 63 | | |
46 | 64 | | |
| |||
0 commit comments