From 163f4bf322b65a3e9d55f3559ea589d63ff30f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Krajcsovits?= Date: Sun, 1 Mar 2026 11:25:58 +0100 Subject: [PATCH] bench(chunkenc): add t=gap-jitter tPattern to demonstrate XOR18111 efficiency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pattern uses a 60s base interval with a single 10-interval gap at sample 10, followed by 60s ± 30ms jitter. This demonstrates two advantages of XOR18111 over standard XOR: - The gap (dod=540000ms = 9×60000) triggers full mode via multiplier encoding (22 bits vs ~68 bits in standard XOR). - Post-gap delta-of-deltas (≤30ms) use the 7-bit full-mode code (9 bits total) vs XOR compact's minimum 14-bit code (16 bits total), saving 7 bits per sample across the remaining 108 samples. Signed-off-by: György Krajcsovits Co-Authored-By: Claude Sonnet 4.6 --- tsdb/chunkenc/benchmark_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tsdb/chunkenc/benchmark_test.go b/tsdb/chunkenc/benchmark_test.go index e41db74c6b..a570102785 100644 --- a/tsdb/chunkenc/benchmark_test.go +++ b/tsdb/chunkenc/benchmark_test.go @@ -89,6 +89,23 @@ func foreachFmtSampleCase(b *testing.B, fn func(b *testing.B, f fmtCase, s sampl name: "t=jitter", next: func(t int64, i int) int64 { return t + rInts[i] - 50 + 15000 }, }, + { + // First 10 samples at constant 60s, then one 10-interval gap (600s), + // then 60s ± 30ms jitter. The gap triggers XOR18111 full mode via + // multiplier encoding (dod=540000 = 9×60000). Subsequent small-jitter + // delta-of-deltas (≤30ms) use XOR18111's 7-bit full-mode code (9 bits + // total) vs XOR compact's minimum 14-bit code (16 bits total). + name: "t=gap-jitter", + next: func(t int64, i int) int64 { + if i < 10 { + return t + 60000 + } + if i == 10 { + return t + 10*60000 // 10-interval gap; triggers XOR18111 full mode. + } + return t + 60000 + rInts[i]%61 - 30 // 60s ± 30ms jitter. + }, + }, } vPatterns := []vPattern{ {