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

perf: reduce allocs when serving metrics #3208

Merged
merged 1 commit into from
Oct 14, 2024
Merged

perf: reduce allocs when serving metrics #3208

merged 1 commit into from
Oct 14, 2024

Conversation

cgrinds
Copy link
Collaborator

@cgrinds cgrinds commented Oct 14, 2024

This PR uses HTTP chunking to stream the metrics instead of joining all the metrics and writing that single blob.

Scenario

  • Poll sar with single Rest volume collector
  • curl metrics endpoint 240 times
  • take heap dump and report on alloc_space bytes for Prometheus.ServeMetrics

Results

Before change:
457.75 MB is alloced from ServeMetrics

After change:
1 MB is alloced from ServeMetrics

Thanks to ChrisGautcher for reporting

This PR uses HTTP chunking to stream the metrics instead of joining all the metrics and writing that single blob.

## Scenario

- Poll sar with single Rest volume collector
- curl metrics endpoint 240 times
- take heap dump and report on `alloc_space` bytes for `Prometheus.ServeMetrics`

Before change:
457.75 MB is alloced from `ServeMetrics`

After change:
1 MB is alloced from `ServeMetrics`

Thanks to ChrisGautcher for reporting
@Hardikl Hardikl merged commit da7b9b1 into main Oct 14, 2024
6 checks passed
@Hardikl Hardikl deleted the cbg-perf branch October 14, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants