Timestamp Compression
Delta‑of‑Delta
Metrics arrive at regular intervals — every 15 s, 30 s, 60 s. Delta-of-delta exploits that regularity: perfectly spaced timestamps compress to 1 bit each, 64× smaller than raw. Drag the jitter slider and watch compression degrade in real time.
Why this matters: Prometheus timestamps are 64-bit nanosecond integers — 8 bytes each. At 1 sample/15 s, 1 million timestamps = 8 MB. With Delta-of-Delta encoding, a perfectly regular 15-second interval costs just 1 bit per sample — 125 KB for the same million samples, a 64× reduction.
① Tune the Signal
Choose an interval and add jitter to simulate real-world clock drift.
Timestamps are compressed in a 4-step chain:
- Raw → Δ (delta): record the gap between consecutive timestamps instead of the timestamps themselves. Regular 15-second intervals → all deltas = 15,000,000,000 ns.
- Δ → ΔoΔ (delta-of-delta): record how much each delta changed. Perfect regularity → ΔoΔ = 0 every time.
- ΔoΔ → ZigZag: map signed integers to unsigned so small negatives get small codes.
- ZigZag → Tier: pick the shortest bit pattern that fits the value.
② Transformation Table
Each row shows one timestamp flowing through the pipeline.
| # | Timestamp | Δ | ΔoΔ | ZigZag | Tier | Prefix | Bits |
|---|
③ Tier Distribution
How values spread across encoding tiers — green is cheapest.
④ Bit Cost Profile
Each bar = one timestamp's encoding cost. Shorter is better.