Repository navigation
fix(nhcb): do not return nhcb from parse if exponential is present - #15209
Merged
Merged
Conversation
krajorama
force-pushed
the
nhcb-scrape-impl
branch
from
October 24, 2024 08:41
eb147bc to
a18042a
Compare
From: #14978 (comment) Also encode the requirement table set in #13532 Signed-off-by: György Krajcsovits <[email protected]>
krajorama
force-pushed
the
nhcb-scrape-impl
branch
from
October 24, 2024 08:44
a18042a to
8e607d9
Compare
krajorama
requested review from
beorn7,
bwplotka,
carrieedwards and
fionaliao
October 24, 2024 08:46
jesusvazquez
approved these changes
Oct 24, 2024
jesusvazquez
left a comment
Member
There was a problem hiding this comment.
LGTM! Very clear code to me
krajorama
commented
Oct 24, 2024
| {Labels: labels.FromStrings("id", "something-test"), Value: 0.5}, | ||
| {Labels: labels.FromStrings("id", "something-test"), Value: 8.0}, | ||
| }, | ||
| // TODO(krajorama): ct: int64p(1520430001000), |
Member
Author
There was a problem hiding this comment.
note to reviewers: input doesn't have created timestamp, copy paste error to have this comment.
krajorama
commented
Oct 24, 2024
| {Labels: labels.FromStrings("id", "something-test"), Value: 0.0, HasTs: true, Ts: 123321}, | ||
| {Labels: labels.FromStrings("id", "something-test"), Value: 2e100, HasTs: true, Ts: 123000}, | ||
| }, | ||
| // TODO(krajorama): ct: int64p(1520430002000), |
Member
Author
There was a problem hiding this comment.
note to reviewers: input doesn't have created timestamp, copy paste error to have this comment.
julienduchesne
pushed a commit
to julienduchesne/prometheus
that referenced
this pull request
Dec 13, 2024
1 task done
krajorama
pushed a commit
that referenced
this pull request
Jul 28, 2026
NHCBParser.hBuffer was added in #15209 as a scratch buffer for labels.Labels.HashWithoutLabels, but it is never assigned: all three call sites discard the returned slice with `_`. HashWithoutLabels uses the pass-and-return buffer idiom, handing back the possibly-reallocated slice so the caller can retain the grown capacity. Because the return value is dropped, p.hBuffer stays nil forever and every call replays the full append growth cascade (16->32->64->128) from zero, costing ~4 allocations per call where an amortised reuse costs none. differentMetric() runs once per classic-histogram series, so this scales with histogram cardinality. hBuffer is pure scratch: it is never returned, stored or aliased, and its only consumer is xxhash.Sum64. This is deliberately not the buffer removed in 41c7f7d ("don't reuse the buffer"), which backed p.bytes - that one *is* handed to callers via Series() and must not be reused. No behaviour change. Using the existing BenchmarkParseOpenMetricsNHCB unchanged (-benchtime 1s -count 6 -cpu 2 -benchmem), via benchstat: B/op allocs/op omtext 22.39Ki -> 22.39Ki ~ 375 -> 375 ~ omtext_with_nhcb 20.02Ki -> 14.89Ki -25.61% 353 -> 181 -48.73% The non-NHCB arm is bit-for-bit unchanged, confirming the fix is confined to the NHCB path. Co-authored-by: Copilot <[email protected]> Signed-off-by: Shubh Gupta <[email protected]>
krajorama
added a commit
that referenced
this pull request
Jul 28, 2026
NHCBParser.hBuffer was added in #15209 as a scratch buffer for labels.Labels.HashWithoutLabels, but it is never assigned: all three call sites discard the returned slice with `_`. HashWithoutLabels uses the pass-and-return buffer idiom, handing back the possibly-reallocated slice so the caller can retain the grown capacity. Because the return value is dropped, p.hBuffer stays nil forever and every call replays the full append growth cascade (16->32->64->128) from zero, costing ~4 allocations per call where an amortised reuse costs none. differentMetric() runs once per classic-histogram series, so this scales with histogram cardinality. hBuffer is pure scratch: it is never returned, stored or aliased, and its only consumer is xxhash.Sum64. This is deliberately not the buffer removed in 41c7f7d ("don't reuse the buffer"), which backed p.bytes - that one *is* handed to callers via Series() and must not be reused. No behaviour change. Using the existing BenchmarkParseOpenMetricsNHCB unchanged (-benchtime 1s -count 6 -cpu 2 -benchmem), via benchstat: B/op allocs/op omtext 22.39Ki -> 22.39Ki ~ 375 -> 375 ~ omtext_with_nhcb 20.02Ki -> 14.89Ki -25.61% 353 -> 181 -48.73% The non-NHCB arm is bit-for-bit unchanged, confirming the fix is confined to the NHCB path. Signed-off-by: Shubh Gupta <[email protected]> Co-authored-by: Shubh Gupta <[email protected]> Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From: #14978 (comment)
Also encode the requirement table set in #13532
This relies on protobuf parser exposing native histograms before classic series and that text format exposers follow the requirement about ordering: proposals/2024-01-29_native_histograms_text_format.md.