Skip to content

tsdb(wal): st-per-sample initial code and benchmarks#17671

Merged
ywwg merged 1 commit into
feature/start-timefrom
owilliams/st-wal
Feb 12, 2026
Merged

tsdb(wal): st-per-sample initial code and benchmarks#17671
ywwg merged 1 commit into
feature/start-timefrom
owilliams/st-wal

Conversation

@ywwg

@ywwg ywwg commented Dec 10, 2025

Copy link
Copy Markdown
Member

Implement an experimental "SamplesV2" encoding method that includes support for Start Time per sample. Part of #17790. Since each slice of refs is only one sample per series, compression quality will be highly dependent on how similar data is between series, ie similar scrape times or start times.

This is a very partial implementation, consisting only of regular counter support as proof-of-concept and not for histograms. This feature is off by default, but tests have been updated to use it. Configuration options exist for the feature for future use by a feature flag in the binary.

Benchmarks

A naive implementation should result in a 33% increase in data size since each record goes from 3*64 to 4*64 bits. Numbers better than 33% are an improvement. In this case, because we add a marker byte when the ST is not easily predictable, we would expect a 37% increase at worst.

Current benchmarks... I think I still need to work on generating representative artificial data samples, it's too easy to construct data that compresses much too well.

$ benchstat encode-v1.txt encode-v2.txt
goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
                                                │ encode-v1.txt │            encode-v2.txt             │
                                                │    sec/op     │    sec/op      vs base               │
Encode_Samples/compr=none/data=real1000-2           7.226µ ± 7%    7.593µ ±  7%        ~ (p=0.065 n=6)
Encode_Samples/compr=none/data=real1000-dst-2       6.869µ ± 6%    7.759µ ±  8%  +12.97% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2       6.795µ ± 4%    7.621µ ±  5%  +12.16% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2          8.133µ ± 3%    8.194µ ±  3%        ~ (p=0.699 n=6)
Encode_Samples/compr=none/data=worst1000-st-2       8.008µ ± 3%   13.971µ ±  8%  +74.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2        15.553µ ± 5%    8.569µ ±  6%  -44.91% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2    15.634µ ± 4%    9.005µ ±  3%  -42.40% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2    15.115µ ± 4%    9.351µ ± 14%  -38.14% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2        17.34µ ± 5%    10.07µ ±  2%  -41.92% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2     17.61µ ± 4%    15.07µ ± 15%  -14.39% (p=0.009 n=6)
Encode_Samples/compr=zstd/data=real1000-2           39.37µ ± 7%    13.32µ ±  4%  -66.16% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2       39.60µ ± 7%    13.20µ ±  5%  -66.66% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2       39.41µ ± 6%    12.76µ ±  8%  -67.62% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2          39.99µ ± 4%    15.81µ ±  4%  -60.46% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2       42.50µ ± 5%    22.22µ ±  6%  -47.73% (p=0.002 n=6)
geomean                                             16.88µ         11.04µ        -34.57%

                                                │  encode-v1.txt   │              encode-v2.txt              │
                                                │ B/compressed-rec │ B/compressed-rec  vs base               │
Encode_Samples/compr=none/data=real1000-2             10.70Ki ± 0%       10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-dst-2         10.70Ki ± 0%       10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2         10.70Ki ± 0%       10.77Ki ± 0%   +0.65% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2            12.65Ki ± 0%       12.70Ki ± 0%   +0.40% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-st-2         12.65Ki ± 0%       17.58Ki ± 0%  +39.00% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2            4022.0 ± 0%         544.0 ± 0%  -86.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2        4022.0 ± 0%         545.0 ± 0%  -86.45% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2        4022.0 ± 0%         585.0 ± 0%  -85.45% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2           4528.0 ± 0%         643.0 ± 0%  -85.80% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2        4528.0 ± 0%         887.0 ± 0%  -80.41% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2             1069.00 ± 0%         45.00 ± 0%  -95.79% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2         1072.00 ± 0%         46.00 ± 0%  -95.71% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2         1071.00 ± 0%         86.00 ± 0%  -91.97% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2            1207.00 ± 0%         53.00 ± 0%  -95.61% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2         1207.00 ± 0%         61.00 ± 0%  -94.95% (p=0.002 n=6)
geomean                                               3.725Ki              764.5       -79.96%

                                                │ encode-v1.txt │            encode-v2.txt            │
                                                │     B/rec     │    B/rec      vs base               │
Encode_Samples/compr=none/data=real1000-2          10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-dst-2      10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2      10.70Ki ± 0%   10.77Ki ± 0%   +0.65% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2         12.65Ki ± 0%   12.70Ki ± 0%   +0.40% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-st-2      12.65Ki ± 0%   17.58Ki ± 0%  +39.00% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2        10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2    10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2    10.70Ki ± 0%   10.77Ki ± 0%   +0.65% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2       12.65Ki ± 0%   12.70Ki ± 0%   +0.40% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2    12.65Ki ± 0%   17.58Ki ± 0%  +39.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2          10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2      10.70Ki ± 0%   10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2      10.70Ki ± 0%   10.77Ki ± 0%   +0.65% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         12.65Ki ± 0%   12.70Ki ± 0%   +0.40% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2      12.65Ki ± 0%   17.58Ki ± 0%  +39.00% (p=0.002 n=6)
geomean                                            11.44Ki        12.27Ki        +7.23%

                                                │ encode-v1.txt │             encode-v2.txt              │
                                                │     B/op      │    B/op     vs base                    │
Encode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=real1000-dst-2      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=real1000-cst-2      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-st-2      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-dst-2    0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-cst-2    0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-st-2    0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-2          2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2      2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2      2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2      2.000 ± 0%     1.000 ± 0%   -50.00% (p=0.002 n=6)
geomean                                                       ²               ?                      ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

                                                │ encode-v1.txt │           encode-v2.txt            │
                                                │   allocs/op   │ allocs/op   vs base                │
Encode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=real1000-dst-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=real1000-cst-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-st-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-dst-2    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-cst-2    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-st-2    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-dst-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-cst-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=worst1000-st-2      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                       ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Does this PR introduce a user-facing change?

Increases size of all WAL RefSample objects by an int64 (a 33% increase) regardless of whether the new ST Storage option is enabled. Prombench does not show significant increase in memory usage, however.

[CHANGE] Adds Start Time value to all WAL RefSamples in memory, and therefore may increase memory usage.

@ywwg

ywwg commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

/prombench

@prombot

prombot commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Incorrect /prombench syntax; no matching command found.

Available Commands:

  • To start benchmark: /prombench <branch or git tag to compare with>
  • To restart benchmark: /prombench <branch or git tag to compare with>
  • To stop benchmark: /prombench cancel
  • To print help: /prombench help

Advanced Flags for start and restart Commands:

  • --bench.directory=<sub-directory of github.com/prometheus/test-infra/prombench
    • See the details here, defaults to manifests/prombench.
  • --bench.version=<branch | @commit>
    • See the details here, defaults to master.

Examples:

  • /prombench v3.0.0
  • /prombench v3.0.0 --bench.version=@aca1803ccf5d795eee4b0848707eab26d05965cc --bench.directory=manifests/prombench

@ywwg

ywwg commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

/prombench main

@prombot

prombot commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️

Compared versions: PR-17671 and main

After the successful deployment (check status here), the benchmarking results can be viewed at:

Available Commands:

  • To restart benchmark: /prombench restart main
  • To stop benchmark: /prombench cancel
  • To print help: /prombench help

@bboreham

Copy link
Copy Markdown
Member

Do you still need Prombench running?

@bboreham

Copy link
Copy Markdown
Member

/prombench cancel

@prombot

prombot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Benchmark cancel is in progress.

@ywwg

ywwg commented Jan 5, 2026

Copy link
Copy Markdown
Member Author

/prombench cancel

@prombot

prombot commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Benchmark cancel is in progress.

@ywwg

ywwg commented Jan 5, 2026

Copy link
Copy Markdown
Member Author

oh nevermind, the dashboard defaults to showing a valid prombench, in this case 17716.

@ywwg

ywwg commented Jan 6, 2026

Copy link
Copy Markdown
Member Author

Changes to the serialization of samples:

  • store timestamps as a delta to the previous sample, not the first sample. Most samples will be the same distance apart so the deltas will be easily compressible.
  • record start timestamps with a leading byte and then an optional int64: The leading byte can be 0 (no ST), 1 (same as prev timestamp), 2 (same as previous ST), or 3 (delta to last ST).

As long as my assumptions about what these slices of SampleRefs usually look like, this should be an improvement across the board:

"v0" here is a naive encoding of ST with every record similar to how T is recorded, as a delta with the first sample.

goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
                                                │ encode-v0.txt │            encode-v1.txt            │
                                                │    sec/op     │    sec/op     vs base               │
Encode_Samples/compr=none/data=real1000-2         10.930µ ± 11%   8.396µ ±  9%  -23.18% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-dst-2     10.500µ ±  2%   8.249µ ±  5%  -21.44% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2      9.845µ ±  2%   8.150µ ±  7%  -17.22% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2         11.14µ ±  6%   11.88µ ±  8%   +6.55% (p=0.026 n=6)
Encode_Samples/compr=none/data=worst1000-st-2      13.39µ ±  8%   17.88µ ±  7%  +33.53% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2       22.558µ ±  3%   8.683µ ±  7%  -61.51% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2   27.897µ ±  2%   9.278µ ±  6%  -66.74% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2   21.872µ ±  6%   9.318µ ±  4%  -57.40% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2       20.51µ ±  4%   12.83µ ±  7%  -37.45% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2    23.76µ ± 12%   19.35µ ±  5%  -18.58% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2          65.21µ ±  7%   14.43µ ± 16%  -77.88% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2      72.03µ ±  2%   15.09µ ±  5%  -79.05% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2      62.24µ ± 10%   15.27µ ±  3%  -75.47% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         47.99µ ± 10%   18.92µ ±  4%  -60.57% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2      49.14µ ±  8%   24.30µ ±  6%  -50.56% (p=0.002 n=6)
geomean                                            24.71µ         12.65µ        -48.79%

                                                │  encode-v0.txt   │              encode-v1.txt              │
                                                │ B/compressed-rec │ B/compressed-rec  vs base               │
Encode_Samples/compr=none/data=real1000-2             12.59Ki ± 0%       10.75Ki ± 0%  -14.68% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-dst-2         13.51Ki ± 0%       10.75Ki ± 0%  -20.42% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2         12.59Ki ± 0%       10.75Ki ± 0%  -14.65% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2            13.63Ki ± 0%       14.65Ki ± 0%   +7.45% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-st-2         15.59Ki ± 0%       19.53Ki ± 0%  +25.31% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2            6969.0 ± 0%         544.0 ± 0%  -92.19% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2        6969.0 ± 0%         548.0 ± 0%  -92.14% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2        6975.0 ± 0%         548.0 ± 0%  -92.14% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2           4531.0 ± 0%         738.0 ± 0%  -83.71% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2        4659.0 ± 0%         981.0 ± 0%  -78.94% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2             3085.00 ± 0%         45.00 ± 0%  -98.54% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2         4192.00 ± 0%         49.00 ± 0%  -98.83% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2         3091.00 ± 0%         49.00 ± 0%  -98.41% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2            1203.00 ± 0%         54.00 ± 0%  -95.51% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2         1216.00 ± 0%         61.00 ± 0%  -94.98% (p=0.002 n=6)
geomean                                               5.561Ki              761.7       -86.62%

                                                │ encode-v0.txt │            encode-v1.txt            │
                                                │     B/rec     │    B/rec      vs base               │
Encode_Samples/compr=none/data=real1000-2          12.59Ki ± 0%   10.75Ki ± 0%  -14.68% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-dst-2      13.51Ki ± 0%   10.75Ki ± 0%  -20.42% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-cst-2      12.59Ki ± 0%   10.75Ki ± 0%  -14.65% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2         13.63Ki ± 0%   14.65Ki ± 0%   +7.45% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-st-2      15.59Ki ± 0%   19.53Ki ± 0%  +25.31% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2        12.59Ki ± 0%   10.75Ki ± 0%  -14.68% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-dst-2    13.51Ki ± 0%   10.75Ki ± 0%  -20.42% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-cst-2    12.59Ki ± 0%   10.75Ki ± 0%  -14.65% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2       13.63Ki ± 0%   14.65Ki ± 0%   +7.45% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-st-2    15.59Ki ± 0%   19.53Ki ± 0%  +25.31% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2          12.59Ki ± 0%   10.75Ki ± 0%  -14.68% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-dst-2      13.51Ki ± 0%   10.75Ki ± 0%  -20.42% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-cst-2      12.59Ki ± 0%   10.75Ki ± 0%  -14.65% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         13.63Ki ± 0%   14.65Ki ± 0%   +7.45% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-st-2      15.59Ki ± 0%   19.53Ki ± 0%  +25.31% (p=0.002 n=6)
geomean                                            13.54Ki        12.89Ki        -4.84%

@ywwg

ywwg commented Jan 6, 2026

Copy link
Copy Markdown
Member Author

some of these numbers are a little suspicious (98%?) so I will keep checking

@ywwg

ywwg commented Jan 7, 2026

Copy link
Copy Markdown
Member Author

In very promising news, I had to make some tests bigger because the new written WAL size is so much smaller

@ywwg ywwg changed the title WIP: Start Time in WAL: initial code and benchmarks tsdb(wal): st-per-sample initial code and benchmarks Jan 7, 2026
@ywwg
ywwg marked this pull request as ready for review January 7, 2026 18:18
@ywwg
ywwg marked this pull request as draft January 8, 2026 15:20
Comment thread util/testrecord/record.go Outdated
Comment thread util/testrecord/record.go

@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 for this! Looks really good, just minor naming suggestions.

I am curious about using a more efficient per-sample delta encoding statements. Is V1 really less efficient than V2? How? 🤔 (V2 only adds more info in general, except first sample)

Comment thread tsdb/agent/db.go Outdated
Comment thread tsdb/compression/compression.go
Comment thread tsdb/compression/compression.go Outdated
Comment thread tsdb/record/bench_test.go Outdated
Comment thread tsdb/record/bench_test.go
Comment thread tsdb/record/record.go Outdated
Comment thread tsdb/record/record.go Outdated
Comment thread tsdb/record/record.go Outdated
Comment thread tsdb/record/record.go Outdated
Comment thread tsdb/record/record.go
@ywwg

ywwg commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

I am curious about using a more efficient per-sample delta encoding statements. Is V1 really less efficient than V2? How? 🤔 (V2 only adds more info in general, except first sample)

yes you're right, this text was leftover from my previous version which turned out not to be correct. I'll change the wording.

@bwplotka

Copy link
Copy Markdown
Member

What's the latest benchmark against V1 without ST support?

@ywwg

ywwg commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

I'm still working on the changes. I'll mark as ready for review when I've got the updated numbers.

@ywwg

ywwg commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

ok here's the benchstat comparison: only valid for the non-st examples since v1 doesn't support st:

$ benchstat encode-v1.txt encode-v2.txt
goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
                                                │ encode-v1.txt │            encode-v2.txt            │
                                                │    sec/op     │    sec/op     vs base               │
Encode_Samples/compr=none/data=real1000-2          7.009µ ± 36%   8.164µ ± 38%        ~ (p=0.065 n=6)
Encode_Samples/compr=none/data=worst1000-2         7.343µ ±  2%   9.049µ ±  2%  +23.23% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2       15.366µ ±  4%   8.200µ ±  5%  -46.63% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2       16.81µ ±  2%   10.58µ ±  3%  -37.07% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2          37.19µ ±  1%   14.25µ ±  2%  -61.68% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         38.79µ ±  2%   16.80µ ±  2%  -56.68% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-vst-2                     12.43µ ± 20%
Encode_Samples/compr=none/data=real1000-cst-2                     7.262µ ±  3%
Encode_Samples/compr=none/data=worst1000-st-2                     14.92µ ±  3%
Encode_Samples/compr=snappy/data=real1000-vst-2                   14.14µ ±  5%
Encode_Samples/compr=snappy/data=real1000-cst-2                   8.489µ ±  2%
Encode_Samples/compr=snappy/data=worst1000-st-2                   16.51µ ±  1%
Encode_Samples/compr=zstd/data=real1000-vst-2                     19.85µ ±  0%
Encode_Samples/compr=zstd/data=real1000-cst-2                     14.96µ ±  2%
Encode_Samples/compr=zstd/data=worst1000-st-2                     23.90µ ±  4%
geomean                                            16.36µ         12.52µ        -34.35%

                                                │  encode-v1.txt   │              encode-v2.txt              │
                                                │ B/compressed-rec │ B/compressed-rec  vs base               │
Encode_Samples/compr=none/data=real1000-2             10.70Ki ± 0%       10.75Ki ± 0%   +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2            12.65Ki ± 0%       12.70Ki ± 0%   +0.40% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2            4022.0 ± 0%         544.0 ± 0%  -86.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2           4528.0 ± 0%         643.0 ± 0%  -85.80% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2             1069.00 ± 0%         45.00 ± 0%  -95.79% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2            1207.00 ± 0%         53.00 ± 0%  -95.61% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-vst-2                            13.97Ki ± 0%
Encode_Samples/compr=none/data=real1000-cst-2                            10.75Ki ± 0%
Encode_Samples/compr=none/data=worst1000-st-2                            17.58Ki ± 0%
Encode_Samples/compr=snappy/data=real1000-vst-2                            750.0 ± 0%
Encode_Samples/compr=snappy/data=real1000-cst-2                            545.0 ± 0%
Encode_Samples/compr=snappy/data=worst1000-st-2                            888.0 ± 0%
Encode_Samples/compr=zstd/data=real1000-vst-2                              95.00 ± 0%
Encode_Samples/compr=zstd/data=real1000-cst-2                              46.00 ± 0%
Encode_Samples/compr=zstd/data=worst1000-st-2                              60.00 ± 0%
geomean                                               3.774Ki              795.3       -81.84%

                                                │ encode-v1.txt │           encode-v2.txt            │
                                                │     B/rec     │    B/rec      vs base              │
Encode_Samples/compr=none/data=real1000-2          10.70Ki ± 0%   10.75Ki ± 0%  +0.47% (p=0.002 n=6)
Encode_Samples/compr=none/data=worst1000-2         12.65Ki ± 0%   12.70Ki ± 0%  +0.40% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=real1000-2        10.70Ki ± 0%   10.75Ki ± 0%  +0.47% (p=0.002 n=6)
Encode_Samples/compr=snappy/data=worst1000-2       12.65Ki ± 0%   12.70Ki ± 0%  +0.40% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=real1000-2          10.70Ki ± 0%   10.75Ki ± 0%  +0.47% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         12.65Ki ± 0%   12.70Ki ± 0%  +0.40% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-vst-2                     13.97Ki ± 0%
Encode_Samples/compr=none/data=real1000-cst-2                     10.75Ki ± 0%
Encode_Samples/compr=none/data=worst1000-st-2                     17.58Ki ± 0%
Encode_Samples/compr=snappy/data=real1000-vst-2                   13.97Ki ± 0%
Encode_Samples/compr=snappy/data=real1000-cst-2                   10.75Ki ± 0%
Encode_Samples/compr=snappy/data=worst1000-st-2                   17.58Ki ± 0%
Encode_Samples/compr=zstd/data=real1000-vst-2                     13.97Ki ± 0%
Encode_Samples/compr=zstd/data=real1000-cst-2                     10.75Ki ± 0%
Encode_Samples/compr=zstd/data=worst1000-st-2                     17.58Ki ± 0%
geomean                                            11.63Ki        12.92Ki       +0.43%

                                                │ encode-v1.txt │             encode-v2.txt              │
                                                │     B/op      │    B/op     vs base                    │
Encode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-2          2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.002 n=6)
Encode_Samples/compr=zstd/data=worst1000-2         2.000 ± 0%     0.000 ±  ?  -100.00% (p=0.002 n=6)
Encode_Samples/compr=none/data=real1000-vst-2                     0.000 ± 0%
Encode_Samples/compr=none/data=real1000-cst-2                     0.000 ± 0%
Encode_Samples/compr=none/data=worst1000-st-2                     0.000 ± 0%
Encode_Samples/compr=snappy/data=real1000-vst-2                   0.000 ± 0%
Encode_Samples/compr=snappy/data=real1000-cst-2                   0.000 ± 0%
Encode_Samples/compr=snappy/data=worst1000-st-2                   0.000 ± 0%
Encode_Samples/compr=zstd/data=real1000-vst-2                     1.000 ± 0%
Encode_Samples/compr=zstd/data=real1000-cst-2                     0.000 ± 0%
Encode_Samples/compr=zstd/data=worst1000-st-2                     1.000 ± 0%
geomean                                                       ²               ?                      ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

                                                │ encode-v1.txt │           encode-v2.txt            │
                                                │   allocs/op   │ allocs/op   vs base                │
Encode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=zstd/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Encode_Samples/compr=none/data=real1000-vst-2                     0.000 ± 0%
Encode_Samples/compr=none/data=real1000-cst-2                     0.000 ± 0%
Encode_Samples/compr=none/data=worst1000-st-2                     0.000 ± 0%
Encode_Samples/compr=snappy/data=real1000-vst-2                   0.000 ± 0%
Encode_Samples/compr=snappy/data=real1000-cst-2                   0.000 ± 0%
Encode_Samples/compr=snappy/data=worst1000-st-2                   0.000 ± 0%
Encode_Samples/compr=zstd/data=real1000-vst-2                     0.000 ± 0%
Encode_Samples/compr=zstd/data=real1000-cst-2                     0.000 ± 0%
Encode_Samples/compr=zstd/data=worst1000-st-2                     0.000 ± 0%
geomean                                                       ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

decode:

$ benchstat decode-v1.txt decode-v2.txt
goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
                                                │ decode-v1.txt │            decode-v2.txt             │
                                                │    sec/op     │    sec/op      vs base               │
Decode_Samples/compr=none/data=real1000-2           8.130µ ± 1%   11.881µ ± 42%  +46.14% (p=0.002 n=6)
Decode_Samples/compr=none/data=worst1000-2          8.771µ ± 1%   10.998µ ± 10%  +25.39% (p=0.002 n=6)
Decode_Samples/compr=snappy/data=real1000-2         11.33µ ± 1%    13.45µ ±  3%  +18.75% (p=0.002 n=6)
Decode_Samples/compr=snappy/data=worst1000-2        11.78µ ± 1%    13.04µ ±  4%  +10.71% (p=0.002 n=6)
Decode_Samples/compr=zstd/data=real1000-2           20.66µ ± 0%    14.28µ ±  0%  -30.85% (p=0.002 n=6)
Decode_Samples/compr=zstd/data=worst1000-2          21.17µ ± 0%    15.30µ ±  2%  -27.76% (p=0.002 n=6)
Decode_Samples/compr=none/data=real1000-vst-2                      17.10µ ±  1%
Decode_Samples/compr=none/data=real1000-cst-2                      11.80µ ±  8%
Decode_Samples/compr=none/data=worst1000-st-2                      14.87µ ±  1%
Decode_Samples/compr=snappy/data=real1000-vst-2                    18.13µ ±  1%
Decode_Samples/compr=snappy/data=real1000-cst-2                    13.45µ ±  2%
Decode_Samples/compr=snappy/data=worst1000-st-2                    17.85µ ±  4%
Decode_Samples/compr=zstd/data=real1000-vst-2                      21.27µ ±  4%
Decode_Samples/compr=zstd/data=real1000-cst-2                      14.57µ ±  1%
Decode_Samples/compr=zstd/data=worst1000-st-2                      22.64µ ± 15%
geomean                                             12.68µ         15.05µ         +3.14%

                                                │ decode-v1.txt │           decode-v2.txt            │
                                                │     B/op      │    B/op     vs base                │
Decode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=zstd/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=zstd/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=none/data=real1000-vst-2                     0.000 ± 0%
Decode_Samples/compr=none/data=real1000-cst-2                     0.000 ± 0%
Decode_Samples/compr=none/data=worst1000-st-2                     0.000 ± 0%
Decode_Samples/compr=snappy/data=real1000-vst-2                   0.000 ± 0%
Decode_Samples/compr=snappy/data=real1000-cst-2                   0.000 ± 0%
Decode_Samples/compr=snappy/data=worst1000-st-2                   0.000 ± 0%
Decode_Samples/compr=zstd/data=real1000-vst-2                     0.000 ± 0%
Decode_Samples/compr=zstd/data=real1000-cst-2                     0.000 ± 0%
Decode_Samples/compr=zstd/data=worst1000-st-2                     0.000 ± 0%
geomean                                                       ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                                │ decode-v1.txt │           decode-v2.txt            │
                                                │   allocs/op   │ allocs/op   vs base                │
Decode_Samples/compr=none/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=none/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=snappy/data=real1000-2        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=snappy/data=worst1000-2       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=zstd/data=real1000-2          0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=zstd/data=worst1000-2         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Decode_Samples/compr=none/data=real1000-vst-2                     0.000 ± 0%
Decode_Samples/compr=none/data=real1000-cst-2                     0.000 ± 0%
Decode_Samples/compr=none/data=worst1000-st-2                     0.000 ± 0%
Decode_Samples/compr=snappy/data=real1000-vst-2                   0.000 ± 0%
Decode_Samples/compr=snappy/data=real1000-cst-2                   0.000 ± 0%
Decode_Samples/compr=snappy/data=worst1000-st-2                   0.000 ± 0%
Decode_Samples/compr=zstd/data=real1000-vst-2                     0.000 ± 0%
Decode_Samples/compr=zstd/data=real1000-cst-2                     0.000 ± 0%
Decode_Samples/compr=zstd/data=worst1000-st-2                     0.000 ± 0%
geomean                                                       ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

@ywwg

ywwg commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

raw stats for v2:

encode:

goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  761253	      7364 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  841173	      7765 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  821106	      8789 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  607332	      8563 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  700848	      7675 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-2         	  684370	     11303 ns/op	     11004 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  377524	     14947 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  498834	     11945 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  494145	     12369 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  440785	     12752 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  429649	     12261 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-vst-2     	  452756	     12485 ns/op	     14304 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  842056	      7265 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  769633	      7474 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  848353	      7392 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  767162	      7197 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  836070	      7259 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=real1000-cst-2     	  773863	      7213 ns/op	     11005 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  645482	      9112 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  671906	      9191 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  662354	      8985 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  635439	      8865 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  674179	      8835 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-2        	  664398	      9152 ns/op	     13005 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  401750	     14906 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  401649	     14942 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  389458	     14967 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  392290	     14528 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  415198	     14661 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=none/data=worst1000-st-2     	  400998	     14927 ns/op	     18005 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  644234	      8226 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  736443	      8138 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  709596	      8174 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  735436	      8169 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  728666	      8423 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-2       	  694887	      8576 ns/op	       544.0 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  428511	     13932 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  420714	     13535 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  446941	     13471 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  414798	     14349 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  415737	     14346 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-vst-2   	  417259	     14346 ns/op	       750.0 B/compressed-rec	     14304 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  635112	      8624 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  704808	      8492 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  680497	      8594 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  706941	      8446 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  661242	      8486 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=real1000-cst-2   	  720152	      8418 ns/op	       545.0 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  593612	     10508 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  574093	     10555 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  566886	     10589 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  570205	     10863 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  497982	     10659 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-2      	  488318	     10564 ns/op	       643.0 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  354393	     16526 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  353739	     16595 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  349950	     16538 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  369567	     16411 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  375116	     16343 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=snappy/data=worst1000-st-2   	  366841	     16489 ns/op	       888.0 B/compressed-rec	     18005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  378411	     14345 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  429811	     13970 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  416524	     14313 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  418082	     14231 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  421027	     14273 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-2         	  427749	     14042 ns/op	        45.00 B/compressed-rec	     11004 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  303722	     19756 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  279168	     19941 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  307836	     19868 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  302392	     19833 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  278490	     19919 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-vst-2     	  300680	     19830 ns/op	        95.00 B/compressed-rec	     14304 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  400544	     15006 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  394814	     14843 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  383432	     14895 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  389326	     14923 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  401988	     15007 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=real1000-cst-2     	  380262	     15199 ns/op	        46.00 B/compressed-rec	     11005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  323403	     16548 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  359490	     16653 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  327163	     16928 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  348856	     16761 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  359624	     16849 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-2        	  360547	     16950 ns/op	        53.00 B/compressed-rec	     13005 B/rec	       0 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  261728	     23052 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  258439	     23887 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  264007	     23201 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  247926	     23953 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  248672	     24030 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
BenchmarkEncode_Samples/compr=zstd/data=worst1000-st-2     	  256196	     23906 ns/op	        60.00 B/compressed-rec	     18005 B/rec	       1 B/op	       0 allocs/op
PASS
ok  	github.com/prometheus/prometheus/tsdb/record	532.062s

decode:

goos: linux
goarch: amd64
pkg: github.com/prometheus/prometheus/tsdb/record
cpu: Intel(R) Core(TM) Ultra 7 155U
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  526706	     11754 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  509400	     12007 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  496311	     16915 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  517798	     10816 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  573285	     11231 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-2         	  423328	     12844 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  340950	     17100 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  349075	     17277 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  352119	     17098 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  342338	     17059 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  342469	     17095 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-vst-2     	  349936	     17002 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  538458	     10840 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  557524	     10800 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  555237	     11929 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  495652	     11944 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  503395	     11938 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=real1000-cst-2     	  501219	     11671 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  484801	     12109 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  492474	     11512 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  493880	     10949 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  540548	     10835 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  546429	     11000 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-2        	  500002	     10996 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  386938	     14863 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  400447	     15012 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  399072	     14815 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  395821	     14869 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  340473	     14949 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=none/data=worst1000-st-2     	  367514	     14827 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  445912	     13528 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  429070	     13490 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  425196	     13811 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  410790	     13348 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  450992	     13419 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-2       	  453333	     13381 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  333100	     18144 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  332412	     18341 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  328696	     18207 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  334639	     18073 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  332470	     18119 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-vst-2   	  332828	     18091 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  453740	     13428 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  402936	     13589 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  422420	     13711 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  413635	     13365 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  411169	     13466 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=real1000-cst-2   	  448012	     13282 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  459267	     12985 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  456561	     12976 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  451118	     13002 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  450477	     13078 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  467042	     13352 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-2      	  429194	     13611 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  347098	     17132 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  351930	     17738 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  326385	     18573 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  318135	     18522 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  345037	     17146 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=snappy/data=worst1000-st-2   	  321580	     17954 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  404439	     14295 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  419455	     14273 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  422425	     14303 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  391317	     14346 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  417963	     14234 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-2         	  405621	     14267 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  281848	     22140 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  270488	     21302 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  286003	     21258 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  278365	     21261 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  282261	     21201 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-vst-2     	  286578	     21269 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  413342	     14757 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  421016	     14557 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  404640	     14579 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  421264	     14772 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  396406	     14529 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=real1000-cst-2     	  409375	     14490 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  395451	     15042 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  402904	     15520 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  369980	     15386 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  392205	     15226 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  370260	     15364 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-2        	  396736	     15132 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  265179	     22448 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  234484	     22541 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  260234	     22661 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  259591	     22615 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  264483	     22860 ns/op	       0 B/op	       0 allocs/op
BenchmarkDecode_Samples/compr=zstd/data=worst1000-st-2     	  253290	     26075 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/prometheus/prometheus/tsdb/record	534.412s

@ywwg
ywwg marked this pull request as ready for review January 14, 2026 17:08
@ywwg

ywwg commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

/prombench

@bwplotka

bwplotka commented Feb 4, 2026

Copy link
Copy Markdown
Member

/prombench cancel

@prombot

prombot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Benchmark cancel is in progress.

@ywwg

ywwg commented Feb 5, 2026

Copy link
Copy Markdown
Member Author

What we've decided to do is create a new feature branch based on this PR instead of merging it to main. so @bwplotka, let's do a last review round, and then instead of merging I'll push to a feature branch and close this PR.

@ywwg
ywwg requested a review from bwplotka February 5, 2026 20:01
@ywwg
ywwg changed the base branch from main to feature/start-time February 10, 2026 15:58

@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! Overall good. Reviewed mostly, but still didn't review the exact code for enc/Dec in details.

My point so far is to probably start using st on appenderV2 with the flag in this PR. Changing tests when this is not yet implemented is a bit odd, although we expect to do in the follow up 🙈

Comment thread tsdb/agent/db_append_v2_test.go Outdated
Comment thread tsdb/agent/db_append_v2_test.go Outdated
require.NoError(t, err)
walSeriesCount += len(series)

case record.Samples, record.SamplesV2:

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.

Should we actually assert V2 for enabled storage? I guess that means we change appender code to actually use flag. Let's either do this or not change tests, perhaps?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added asserts to confirm the correct type is used based on the test run

Comment thread tsdb/db_test.go Outdated
Comment thread tsdb/db_test.go
s3 := labels.FromStrings("e", "f")
s4 := labels.FromStrings("g", "h")
for _, enableStStorage := range []bool{false, true} {
t.Run("enableStStorage="+strconv.FormatBool(enableStStorage), func(t *testing.T) {

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.

ditto

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm confused here, doesn't this follow the format since it's enableStStorage=[true/false]? Maybe I misunderstand the "case=a" format you describe.

Comment thread tsdb/head.go Outdated
Comment thread tsdb/head_test.go
}
// Add a sample so that the series is not garbage collected.
samplesRec := record.RefSample{Ref: ref, T: 1000, V: 1000}
enc := record.Encoder{EnableSTStorage: enableStStorage}

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.

We can skip appendV1 tests changes. Appender V1 will never use new WAL formats

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

does that mean I can revert all v2 tests in non _v2 files?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ah it looks like this is the only one anyway

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.

Yes

@ywwg

ywwg commented Feb 10, 2026

Copy link
Copy Markdown
Member Author

Addressed notes, thanks!

@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.

Something went wrong with this PR?

Maybe you tried merging main changes? It's very hard to review this form.

Let's focus on ST WAL only change in one PR, then main merges in another PRs (also I'd prefer if we honestly rebase the feature branch (much more cleaner)).

Comment thread .github/workflows/ci.yml
@bwplotka

Copy link
Copy Markdown
Member

Yea, can you rebase and add only your commits in this PR?

image

Comment thread tsdb/wlog/watcher_test.go
@ywwg

ywwg commented Feb 11, 2026

Copy link
Copy Markdown
Member Author

diff should be clean now

@ywwg
ywwg requested a review from bwplotka February 12, 2026 13:37

@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.

LGTM just tiny comment nits, we can fix later. Thanks!

Comment thread tsdb/record/record_test.go Outdated
Comment thread tsdb/record/record_test.go Outdated
Comment thread tsdb/record/record_test.go Outdated
Comment thread tsdb/db_append_v2_test.go Outdated
Comment thread tsdb/db_append_v2_test.go Outdated
Initial implementation of #17790.
Only implements ST-per-sample for Counters. Tests and benchmarks updated.

Note: This increases the size of the RefSample object for all users, whether st-per-sample is turned on or not.

Signed-off-by: Owen Williams <[email protected]>
@ywwg
ywwg merged commit b57f5b5 into feature/start-time Feb 12, 2026
23 of 24 checks passed
@ywwg
ywwg deleted the owilliams/st-wal branch February 12, 2026 18:17
bwplotka added a commit that referenced this pull request Mar 19, 2026
…ncoding` (#18062)

* feat(tsdb/chunkenc): add float chunk format with start timestamp support


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

* optimize code path and layout

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

* make new format usable in head

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

* fix issue with seeking to last sample again

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

* fix iterator benchmark for chunks not supporting ST

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

* reduce footprint of the xoroptst chunk iterator object

It was 80 bytes with a lot of padding compared to the 56 bytes of the
original xor chunk iterator. Made it 64 bytes, tightly packed.

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

* Fix benchmark expectations on ST in interator

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

* add inclusive delta test case

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

* make testcases independent of order

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

* drop unused code

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

* Drop commented out line

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

* documentation

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

* Small simplification in the doc

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

* Add delta st inclusive test case for random vt

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

* Switch to delta of difference of st to prev t

from delta of delta of st.

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

* Write ST after T and V so we can write a single bit on the second sample

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

* verify chunk sample len function

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

* Reduce size of first st stored a little

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

* test the case where st equals the t

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

* add st equal t to bechmarks

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

* test(chunkenc): test that appender can contonue chunks

Test that initializing a chunk appender from an existing chunk
works correctly.

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

* fix(chunkenc): bug in initializing appender on existing chunk

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

* Add cases with jitter in the start time as well


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

* tsdb: ST-in-WAL: Counter implementation and benchmarks (#17671)

Initial implementation of #17790.
Only implements ST-per-sample for Counters. Tests and benchmarks updated.

Note: This increases the size of the RefSample object for all users, whether st-per-sample is turned on or not.

Signed-off-by: Owen Williams <[email protected]>

* refactor: sed enableStStorage/enableSTStorage

Signed-off-by: bwplotka <[email protected]>

* feat[scrape]: add ST parsing support to scrape AppenderV2 flow (#18103)

Signed-off-by: bwplotka <[email protected]>

* feat(tsdb): change head opt EnableSTStorage to atomic (#18107)

In downstream projects this needs to be set dynamically per tenant.

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

* Merge pull request #18108 from prometheus/bwplotka/fix

scrape: add tests for ST appending; add warnings for ST feature flag users around _created drop

* refact(tsdb): trivial rename (#18109)

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

* fix(tsdb): missing passing head option to wal/wbl write (#18113)

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

* feat(tsdb): allow using ST capable XOR chunks - retain format on read (#18013)

* feat(tsdb): allow appending to ST capable XOR chunk optionally

Only for float samples as of now.  Supports for in-order and out-of-order
samples.

Make sure that on readout the ST capable chunks are returned automatically.
When the chunks are returned as is, this is trivially true.
When a chunk needs to be re-coded due to deletion (tombstone) markers,
we take the encoding of the original chunk.
When a chunk needs to be created from overlapping chunks, we observe
whether ST is zero or not and create the new chunk based on that.

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

* fix test after merge

Signed-off-by: bwplotka <[email protected]>

* feat: RW2 sending ST support

Signed-off-by: bwplotka <[email protected]>

tmp

Signed-off-by: bwplotka <[email protected]>

* tests: test ST in a cheapest way possible

Signed-off-by: bwplotka <[email protected]>

* tests: add bench CLI recommended invokations

Signed-off-by: bwplotka <[email protected]>

* fixed tests after rebase

Signed-off-by: bwplotka <[email protected]>

* feat(chunkenc): replace xoroptst chunk encoding with xor2

XOR2 is based on #18238
With additional ST support.

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

* feat: add compliance RW sender test for agent

Signed-off-by: bwplotka <[email protected]>

* feat(agent): add support for appending ST

Signed-off-by: bwplotka <[email protected]>

* replace stray xoroptst words

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

* Apply suggestions from code review

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>

* post merge conflict fixes

Signed-off-by: bwplotka <[email protected]>

* feat(tsdb): register st_storage in feature API

Register the st-storage feature flag in the feature registry via
the TSDB options, consistent with how other TSDB features like
exemplar_storage and delayed_compaction are registered.

Signed-off-by: György Krajcsovits <[email protected]>
Coded with Claude Sonnet 4.6.

* Document xor2-encoding feature flag

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

* Add xor2-encoding feature flag

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

* Update CHANGELOG

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

* Fix linting

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

* Remove setting of xor2 encoding option in db open

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

* Fix tests

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

* Fix linting

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

* Update feature flag description

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

* Update comments and feature flag description

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

* Update documentation for st-storage feature

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

* st: disconnect st-storage with xor2-encoding given planned experiments (#18316)

* st: disconnect st-storage with xor2-encoding given planned experiments

Signed-off-by: bwplotka <[email protected]>

* Update docs/feature_flags.md

Co-authored-by: George Krajcsovits <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>

* Update docs/feature_flags.md

Co-authored-by: George Krajcsovits <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>

* Update docs/feature_flags.md

Co-authored-by: George Krajcsovits <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>

* Update docs/feature_flags.md

Co-authored-by: George Krajcsovits <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>

---------

Signed-off-by: bwplotka <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>
Co-authored-by: George Krajcsovits <[email protected]>

---------

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Aleksandr Smirnov <[email protected]>
Signed-off-by: Mohammad Abbasi <[email protected]>
Signed-off-by: matt-gp <[email protected]>
Signed-off-by: Ian Kerins <[email protected]>
Signed-off-by: SuperQ <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: ffgan <[email protected]>
Signed-off-by: Patryk Prus <[email protected]>
Signed-off-by: Owen Williams <[email protected]>
Signed-off-by: bwplotka <[email protected]>
Signed-off-by: 3Juhwan <[email protected]>
Signed-off-by: Sammy Tran <[email protected]>
Signed-off-by: Casie Chen <[email protected]>
Signed-off-by: Dan Cech <[email protected]>
Signed-off-by: kakabisht <[email protected]>
Signed-off-by: Jeanette Tan <[email protected]>
Signed-off-by: Divyansh Mishra <[email protected]>
Signed-off-by: Varun Chawla <[email protected]>
Signed-off-by: Martin Valiente Ainz <[email protected]>
Signed-off-by: Kyle Eckhart <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Matthieu MOREL <[email protected]>
Signed-off-by: Linas Medziunas <[email protected]>
Signed-off-by: Björn Rabenstein <[email protected]>
Signed-off-by: beorn7 <[email protected]>
Signed-off-by: Sayuru <[email protected]>
Signed-off-by: Matt <[email protected]>
Signed-off-by: Bartlomiej Plotka <[email protected]>
Signed-off-by: Carrie Edwards <[email protected]>
Co-authored-by: Bartlomiej Plotka <[email protected]>
Co-authored-by: Ganesh Vernekar <[email protected]>
Co-authored-by: Bryan Boreham <[email protected]>
Co-authored-by: Sasha <[email protected]>
Co-authored-by: Mohammad Abbasi <[email protected]>
Co-authored-by: matt-gp <[email protected]>
Co-authored-by: Ian Kerins <[email protected]>
Co-authored-by: SuperQ <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arve Knudsen <[email protected]>
Co-authored-by: Julien <[email protected]>
Co-authored-by: ffgan <[email protected]>
Co-authored-by: Patryk Prus <[email protected]>
Co-authored-by: Ganesh Vernekar <[email protected]>
Co-authored-by: Joe Adams <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Owen Williams <[email protected]>
Co-authored-by: 3Juhwan <[email protected]>
Co-authored-by: Casie Chen <[email protected]>
Co-authored-by: Dan Cech <[email protected]>
Co-authored-by: hridyesh bisht <[email protected]>
Co-authored-by: zenador <[email protected]>
Co-authored-by: Divyansh Mishra <[email protected]>
Co-authored-by: Varun Chawla <[email protected]>
Co-authored-by: Martin Valiente Ainz <[email protected]>
Co-authored-by: Kyle Eckhart <[email protected]>
Co-authored-by: Matthieu MOREL <[email protected]>
Co-authored-by: Linas Medžiūnas <[email protected]>
Co-authored-by: Björn Rabenstein <[email protected]>
Co-authored-by: beorn7 <[email protected]>
Co-authored-by: Sayuru <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Carrie Edwards <[email protected]>
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.

6 participants