Skip to content

fix: Reduce allocations for classic histogram buckets #2081

Draft
jaydeluca wants to merge 6 commits intomainfrom
reduce-allocations
Draft

fix: Reduce allocations for classic histogram buckets #2081
jaydeluca wants to merge 6 commits intomainfrom
reduce-allocations

Conversation

@jaydeluca
Copy link
Copy Markdown
Collaborator

@jaydeluca jaydeluca commented Apr 30, 2026

Related to #2075

This reduces allocation and GC pressure in histogram text formatting by improving buffer reuse and eliminating unnecessary intermediate allocations.

I added and ran some benchmarks:

Histogram text formatting

Benchmark Before (ops/s) After (ops/s) Δ Throughput Before (B/op) After (B/op) Δ Allocation
openMetricsReusingWriter 14,487 17,882 +23% 76,128 18,192 -76%
openMetricsWriteToByteArray 14,338 16,588 +16% 77,088 43,648 -43%
prometheusReusingWriter 14,748 18,007 +22% 69,256 18,264 -74%
prometheusWriteToByteArray 14,333 16,588 +16% 76,288 43,720 -43%

GC impact

Benchmark Before GC Count After GC Count Before GC Time After GC Time
openMetricsReusingWriter 54 7 101 ms 16 ms
prometheusReusingWriter 50 7 81 ms 17 ms

@jaydeluca jaydeluca changed the title Reduce allocations for classic histogram buckets feat: Reduce allocations for classic histogram buckets Apr 30, 2026
@jaydeluca jaydeluca changed the title feat: Reduce allocations for classic histogram buckets fix: Reduce allocations for classic histogram buckets Apr 30, 2026
@jaydeluca jaydeluca force-pushed the reduce-allocations branch from 4dbb3cc to 8ad2736 Compare April 30, 2026 21:18
jaydeluca added 4 commits May 1, 2026 16:37
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
@jaydeluca jaydeluca force-pushed the reduce-allocations branch from 494d653 to 5fe88b1 Compare May 1, 2026 20:37
jaydeluca added 2 commits May 2, 2026 11:32
Signed-off-by: Ubuntu <jaydeluca4@gmail.com>
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
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.

1 participant