Skip to content

tsdb: add histograms-st-encoding feature flag - #18912

Merged
krajorama merged 2 commits into
cedwards/st-histogram-encodingfrom
krajo/new-flag
Jun 17, 2026
Merged

krajorama merged 2 commits into
cedwards/st-histogram-encodingfrom
krajo/new-flag

Conversation

@krajorama

Copy link
Copy Markdown
Member

Stacked on top of #18609.

Decouple the ST-capable histogram chunk encodings (EncHistogramST, EncFloatHistogramST) from the xor2-encoding feature flag and gate them behind a new histograms-st-encoding flag instead. Previously --enable-feature=xor2-encoding turned on both the float XOR2 encoding and the histogram ST encodings via a single useXOR2 boolean; that conflated two independent on-disk formats and made it impossible to opt into one without the other.

Changes

  • chunkenc.ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and useHistogramST flags. Dispatch only consumes the relevant flag per value type; data-driven callers that gate on actual ST presence in the samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go) pass hasST for both.
  • tsdb.Options gains EnableHistogramSTEncoding; tsdb.HeadOptions gains a matching atomic.Bool.
  • The new flag is propagated through chunkOpts/headAppenderBase and read at every site that currently reads EnableXOR2Encoding (head append v1/v2, head_wal WAL/WBL replay, ooo_head_read).
  • New --enable-feature=histograms-st-encoding and matching docs section in docs/feature_flags.md.
  • Existing tests that flipped EnableXOR2Encoding for histogram ST behaviour also flip EnableHistogramSTEncoding, preserving pre-split semantics.

The two flags are fully independent: either can be enabled without the other.

Test plan

  • go test ./tsdb/... ./storage/... ./scrape/ ./promql/promqltest/ ./cmd/prometheus/
  • make lint (only pre-existing findings in vendored web/ui/node_modules/flatted/ remain)
NONE

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: György Krajcsovits <[email protected]>

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I think this give us consistency with the current flow.

@krajorama
krajorama merged commit 3b3fada into cedwards/st-histogram-encoding Jun 17, 2026
30 checks passed
@krajorama
krajorama deleted the krajo/new-flag branch June 17, 2026 07:55
carrieedwards pushed a commit that referenced this pull request Jun 17, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>

* update features testdata

Signed-off-by: György Krajcsovits <[email protected]>

---------

Signed-off-by: György Krajcsovits <[email protected]>
krajorama added a commit that referenced this pull request Jun 25, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
carrieedwards pushed a commit that referenced this pull request Jun 29, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
carrieedwards pushed a commit that referenced this pull request Jun 29, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
carrieedwards pushed a commit that referenced this pull request Jun 29, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
carrieedwards pushed a commit that referenced this pull request Jun 30, 2026
* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
carrieedwards added a commit that referenced this pull request Jun 30, 2026
* Add histogram chunk encoding with Start Timestamp support

Signed-off-by: Carrie Edwards <[email protected]>

* Update documentation

Signed-off-by: Carrie Edwards <[email protected]>

* Add more tests

Signed-off-by: Carrie Edwards <[email protected]>

* Fix for appendHistogram

Signed-off-by: Carrie Edwards <[email protected]>

* Linting

Signed-off-by: Carrie Edwards <[email protected]>

* Fix start timestamp for histogram samples in TestCompactingChunkSeriesMerger

Signed-off-by: Carrie Edwards <[email protected]>

* Refactor and reduce code duplication

Signed-off-by: Carrie Edwards <[email protected]>

* Move counter reset hint bits into sample count field

Signed-off-by: Carrie Edwards <[email protected]>

* Fix bug with counter reset header

Signed-off-by: Carrie Edwards <[email protected]>

* Clean up docs

Signed-off-by: Carrie Edwards <[email protected]>

* Address feedback

Signed-off-by: Carrie Edwards <[email protected]>

* Lint

Signed-off-by: Carrie Edwards <[email protected]>

* Refactor to use generic appenders

Signed-off-by: Carrie Edwards <[email protected]>

* Update to include changes to histogram appenders

Signed-off-by: Carrie Edwards <[email protected]>

* Address feedback

Signed-off-by: Carrie Edwards <[email protected]>

* tsdb: add histograms-st-encoding feature flag (#18912)

* tsdb: add histograms-st-encoding feature flag

Decouple the ST-capable histogram chunk encodings (EncHistogramST,
EncFloatHistogramST) from the xor2-encoding feature flag and gate them
behind a new histograms-st-encoding flag instead. Previously
--enable-feature=xor2-encoding turned on both the float XOR2 encoding
and the histogram ST encodings via a single useXOR2 boolean; that
conflated two independent on-disk formats and made it impossible to opt
into one without the other.

ValueType.ChunkEncoding and NewChunk now take separate useXOR2 and
useHistogramST flags. Dispatch only consumes the relevant flag per
value type; data-driven callers that gate on actual ST presence in the
samples (storage/series.go, tsdb/querier.go, tsdb/chunks/chunks.go)
pass hasST for both. tsdb.Options gains EnableHistogramSTEncoding;
tsdb.HeadOptions gains a matching atomic.Bool. The new flag is
propagated through chunkOpts/headAppenderBase and read at every site
that currently reads EnableXOR2Encoding (head append v1/v2, head_wal
WAL/WBL replay, ooo_head_read).

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>

* Address feedback

Signed-off-by: Carrie Edwards <[email protected]>

* Fix histogram tests

Signed-off-by: Carrie Edwards <[email protected]>

* Fix histogram ST PromQL tests

Signed-off-by: Carrie Edwards <[email protected]>

* Fixes for promQL tests

Signed-off-by: Carrie Edwards <[email protected]>

---------

Signed-off-by: Carrie Edwards <[email protected]>
Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
Co-authored-by: George Krajcsovits <[email protected]>
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.

3 participants