bench(chunkenc): add t=gap-jitter tPattern to demonstrate XOR18111 efficiency

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 <gyorgy.krajcsovits@grafana.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
György Krajcsovits 2026-03-01 11:25:58 +01:00
parent 61679a0977
commit 163f4bf322
No known key found for this signature in database
GPG Key ID: 47A8F9CE80FD7C7F

View File

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