Repository navigation
Conversation
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 15:42
ce699ac to
6594bd4
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
3 times, most recently
from
October 1, 2026 16:25
20cda53 to
54dcda7
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 16:34
54dcda7 to
ddffdd6
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 21:28
ddffdd6 to
e867ff5
Compare
bwplotka
marked this pull request as ready for review
October 1, 2026 21:34
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 21:35
e867ff5 to
ddffdd6
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 21:59
ddffdd6 to
9318262
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 22:11
9318262 to
cec2995
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 1, 2026 22:22
cec2995 to
d69edda
Compare
This was referenced Oct 1, 2026
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
2 times, most recently
from
October 3, 2026 14:12
3b20140 to
d3894fd
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
October 4, 2026 12:13
d3894fd to
e4dfbb5
Compare
bwplotka
changed the base branch from
bwplotka/pr-18048-streaming-perf
to
main
October 6, 2026 05:13
This was referenced Nov 3, 2026
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
November 3, 2026 08:31
c54dd0e to
af3db9a
Compare
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
November 5, 2026 05:11
af3db9a to
f55631c
Compare
bwplotka
marked this pull request as ready for review
November 5, 2026 07:09
rbizos
reviewed
Nov 6, 2026
rbizos
reviewed
Nov 6, 2026
rbizos
left a comment
Contributor
There was a problem hiding this comment.
storage/native_histograms_as_classic_test.go: The shadow branch at native_histograms_as_classic.go:1003 (classic sample strictly between two NHCB samples) is exercised by "disjoint timestamps across forward migration cutover" but only with matching labels, so the stale it emits is discarded by mergeSamples. There is no test where that stale must survive because classic doesn't carry the bucket, which is the core reason the shadow exists (lookback-leak / partial-bucket prevention the merge can't handle). Consider a case: NHCB le=5 at t=1 and t=3, classic (no le=5) at t=2, expecting le=5: {t=1,f},{t=2,STALE},{t=3,f}.
…gramsAsClassicQuerier Group stored classic and NHCB series by histogram identity when both representations exist for a metric, while keeping pure-classic and pure-NHCB paths streaming. - Shadow converted NHCB samples at timestamps where a stored classic histogram has a live sample across the histogram group, avoiding hybrid bucket layouts and duplicate series. - Merge disjoint time ranges across classic and NHCB cutovers or rollbacks into a single continuous Series while preserving start timestamps, preferring live samples over StaleNaN at the cutover timestamp, and dropping delayed staleness markers from the old representation. - Propagate StaleNaN onto active converted classic series when an NHCB sample is stale, drops a custom bucket boundary, transitions to an exponential schema or float sample, or yields to stored classic. - Ignore non-histogram _bucket series without an le label during shadowing and skip base series whose first sample is not NHCB. - Sort output series by labels.Compare per group when sortSeries is false and globally across groups when sortSeries is true. Signed-off-by: Bartek Plotka <[email protected]>
…rier classic Select
Dropping le matchers on the classic Select fetched all B+1 bucket series and filtered client-side for selective queries such as foo_bucket{le="+Inf"} or foo_bucket{le="0.5"}, including on the pure-classic fast path when no NHCB series exist.
Shadowing only needs the timestamps at which a stored classic histogram has a live sample, and every classic histogram has a +Inf bucket. Push le matchers down widened to also match +Inf so selective queries fetch at most one extra series per histogram while keeping the original le filter client-side. Matchers that cannot be widened such as le!="+Inf" remain client-side.
Signed-off-by: Bartek Plotka <[email protected]>
…ramsAsClassicQuerier Streaming Queryable implementations such as Mimir do not allow calling Series.Iterator more than once on the same storage.Series. - Carry the iterator and first live NHCB sample from peekNHCBSeries directly into convertPeekedNHCB, and inspect subsequent candidate series lazily on conversion so each NHCB Series.Iterator is opened at most once. - Materialize matching classic float samples into a reusable slab during collectClassicGroup when resolving a hybrid collision group so stored classic Series.Iterator is also opened at most once while pure-classic and pure-NHCB paths stay zero-copy. Signed-off-by: Bartek Plotka <[email protected]>
…cQuerier Signed-off-by: Bartek Plotka <[email protected]>
Signed-off-by: Bartek Plotka <[email protected]>
Signed-off-by: Bartek Plotka <[email protected]>
…stogramsAsClassicQuerier Check ctx.Err() inside selectNHCBAsClassic and nhcbToClassicSeriesSet.Next loops so cancelled queries abort promptly when skipping large numbers of non-NHCB series or indexing classic/NHCB groups. Signed-off-by: Bartek Plotka <[email protected]>
…ClassicQuerier Cover multi-sample FloatHistogram bucket/count/sum conversion, start timestamp preservation, staleness and schema transitions, and classic/NHCB collisions. Signed-off-by: Bartek Plotka <[email protected]>
Verify leFilterSeriesSet strips widened +Inf series on the pure-classic fast path and test warning propagation across all four selectNHCBAsClassic execution paths. Signed-off-by: Bartek Plotka <[email protected]>
…eMatchers test Verify actual sample values (confirming t=1 NHCB buckets are shadowed via widened +Inf pushdown) and cover MatchNotRegexp and extra non-le matchers. Signed-off-by: Bartek Plotka <[email protected]>
Invert the fallback loop guard in mergeSeriesByLabels to satisfy gocritic nestingReduce. Signed-off-by: Bartek Plotka <[email protected]>
…CB samples Verify that shadowing an active NHCB bucket missing from the stored classic histogram emits a StaleNaN at the intermediate classic timestamp that survives merging. Signed-off-by: Bartek Plotka <[email protected]>
…Querier Series.Iterator returns a non-nil chunkenc.Iterator across Prometheus storage implementations (using chunkenc.NewNopIterator when empty), so drop the unused nil checks in peekNHCBSeries, collectClassicGroup, mergeSamples, and nextFloat. Signed-off-by: Bartek Plotka <[email protected]>
Explain in convertPeekedNHCB's doc comment why shadowing emits StaleNaN even when matching labels will override it in mergeSamples: surviving StaleNaN prevents PromQL lookback from leaking converted NHCB buckets absent from the stored classic histogram. Signed-off-by: Bartek Plotka <[email protected]>
…lectClassicGroup Document why collectClassicGroup only buffers native histogram samples while no float sample has been seen (only pure non-float series are preserved via nonFloatClassicSeries) and cover the float-then-histogram ordering in unit tests. Signed-off-by: Bartek Plotka <[email protected]>
bwplotka
force-pushed
the
bwplotka/pr-18048-resolve-collisions
branch
from
November 19, 2026 09:32
f55631c to
30ba5b8
Compare
bwplotka
commented
Nov 19, 2026
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.
Part of #16948. Follow-up to #18048, addressing #18048 review feedback.
Resolves collisions, cutover transitions, staleness propagation, and
sortSeriesordering between stored classic histograms and converted NHCB series inNativeHistogramsAsClassicQuerier:__name__andle, when both representations exist for a queried metric, while keeping pure-classic and pure-NHCB selections streaming.leformatting differences such as"1"versus OpenMetrics"1.0"do not produce duplicate or hybrid buckets.Serieswhile preserving start timestamps, preferring live samples overStaleNaNat the cutover timestamp, and dropping delayed staleness markers from the old representation once the new one is active.StaleNaNonto active converted classic series when an NHCB sample is stale, drops a custom bucket boundary, transitions to an exponential schema or float sample, or yields to stored classic._bucketseries without anlelabel during shadowing and skip base series whose first live sample is not NHCB.lematchers down on the classicSelectwidened with+InfviawithInfBucketso selective queries fetch at most one extra series per histogram instead of all buckets.Series.Iteratorat most once per inputstorage.Seriesacross bothnhcbSetandclassicSetviapeekNHCBSeriesandcollectClassicGroupfor streamingQueryableimplementations.labels.ComparewhensortSeries=trueand per hybrid group whensortSeries=false.Streaming and buffering
After peeking one candidate series from each
SeriesSetinselectNHCBAsClassic, the querier takes one of four paths:SeriesSetstreamingclassicSetreturned directlyleindex pushdown and returns the underlying storageSeriesSetuntouched.sortSeries=falseor_count/_sumnhcbToClassicSeriesSet.Next_countand_sumadd nolelabel, preserving globallabels.Compareorder even whensortSeries=true. Local PromQL passessortSeries=falseand expands one NHCB series into itssortSeries=falseSerieshandle viahistogramIndex, converted 1 group at a time onNext()classicSetandnhcbSetcannot co-stream in lockstep because TSDB iterates internal series-ref order whensortSeries=false, andlesorts before label names above"le"whensortSeries=true. Sample iterators are opened lazily once per group._bucketwithsortSeries=trueNewMergeQuerierwithremote_read. Globallabels.Compareorder interleaves buckets across different NHCB series when label names sort after"le".Commits
storage: resolve classic and NHCB histogram collisions in NativeHistogramsAsClassicQuerier: collision grouping, shadowing, cutover and rollback merging, staleness propagation,sortSerieshandling, and feature flag docs.storage: keep le matchers pushed down in NativeHistogramsAsClassicQuerier classic Select: widens pushed-downlematchers with+Infso selective queries do not scan all stored buckets.storage: avoid calling Series.Iterator multiple times in NativeHistogramsAsClassicQuerier: single-pass iterator consumption for both NHCB and classic series.Benchmarks
go test ./storage -run '^$' -bench '^BenchmarkNativeHistogramsAsClassicSelect' -benchmem -count=6 -cpu=2comparingmain(58719dfa4) vspr(30ba5b867) over 1,000 NHCB series with 30 custom buckets and 6 samples per series:benchstat output