Skip to content

Use non-pointer HistogramBucket slice - #7809

Open
PaurushGarg wants to merge 1 commit into
cortexproject:masterfrom
PaurushGarg:fix/histogram-bucket-non-pointer
Open

Use non-pointer HistogramBucket slice#7809
PaurushGarg wants to merge 1 commit into
cortexproject:masterfrom
PaurushGarg:fix/histogram-bucket-non-pointer

Conversation

@PaurushGarg

@PaurushGarg PaurushGarg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

…esponse encoding

What this PR does:
This PR adds (gogoproto.nullable) = false to the repeated HistogramBucket buckets field - generating []HistogramBucket (values) instead of []*HistogramBucket (pointers). This is consistent with other repeated fields in the same proto (e.g., samples) that already use this annotation.

  • Eliminates per-bucket heap allocation.
  • Reduces per-bucket cost from ~40 bytes (32-byte struct + 8-byte pointer) to ~32 bytes (struct only)
  • ~20% reduction in codec bucket memory for NH responses
  • Reduces per-bucket heap overhead and cuts GC tracing by allocating contiguously.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags

@PaurushGarg
PaurushGarg force-pushed the fix/histogram-bucket-non-pointer branch 3 times, most recently from 3645d37 to 773e0c8 Compare August 25, 2026 04:56
…esponse encoding

Signed-off-by: Paurush Garg <paurushg@amazon.com>
@PaurushGarg
PaurushGarg force-pushed the fix/histogram-bucket-non-pointer branch from 773e0c8 to 490cde8 Compare August 25, 2026 05:03
@PaurushGarg
PaurushGarg marked this pull request as ready for review August 25, 2026 05:05
@PaurushGarg
PaurushGarg requested a review from a team as a code owner August 25, 2026 05:05
@PaurushGarg
PaurushGarg requested a review from yeya24 August 25, 2026 05:05
@dosubot dosubot Bot added go Pull requests that update Go code type/performance labels Aug 25, 2026

@yeya24 yeya24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The change looks good. I ran some benchmark locally for this PR and the result looks good.

Buckets ns/op B/op allocs/op
8 master 1,035 720 11
8 PR 834 640 2
8 Δ −19% −11% −82%
32 master 3,177 1,696 35
32 PR 2,480 1,504 2
32 Δ −22% −11% −94%
160 master 14,586 6,912 163
160 PR 11,157 5,728 2
160 Δ −23% −17% −99%

@SungJin1212

Copy link
Copy Markdown
Member

@PaurushGarg
lgtm, can you get the rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code size/M type/performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants