Sublime: Sublinear Error & Space for Unbounded Skewed Streams

Navid Eslami, Ioana O. Bercea, Rasmus Pagh, Niv Dayan · DOI

TL;DR

Sublime is a new framework that upgrades traditional frequency estimation sketches (like Count-Min Sketch) to handle real-world data skew and infinite streams. By using a novel variable-length encoding (VALE) and dynamically expanding its size as data arrives, it achieves sublinear error growth and massive memory savings without sacrificing high-speed performance.

What Problem Does This Paper Address?

Frequency estimation sketches are the "Swiss Army knives" of stream processing, used everywhere from query optimization in databases to detecting DDoS attacks in networks. They allow us to estimate how often a specific key (like a URL or an IP address) appears in a massive stream of data using very little memory.

However, traditional sketches like the Count-Min Sketch (CMS) have two major "Achilles' heels":

  1. The Skew Problem: Most data streams are highly skewed—a few "heavy hitters" appear millions of times, while most keys appear only once or twice. Traditional sketches use fixed-size counters (e.g., 32 bits) for every slot. This wastes huge amounts of memory on "leading zeros" for the millions of small counts.
  2. The Unbounded Growth Problem: Sketches are usually allocated with a fixed size. As a stream grows indefinitely, the "noise" from hash collisions increases, causing the estimation error to grow linearly with the stream's length. Eventually, the sketch becomes too noisy to be useful.

Methods

The authors introduce Sublime, a framework that generalizes sketches to be adaptive. It relies on two core innovations:

1. VALE (Variable-Length Encoding)

Instead of fixed-width counters, Sublime uses VALE. Each counter starts as a short "stub" (e.g., 4-8 bits) packed into a 512-bit cache line. When a counter overflows its stub, Sublime attaches a variable-length extension.

  • Base-3 Encoding: Extensions are stored as 2-bit fragments representing base-3 digits, with a specific bit pattern (11) acting as a delimiter.
  • Hardware Acceleration: To keep things fast, Sublime uses specialized CPU instructions (POPCNT, PDEP, TZCNT) to perform "rank and select" operations. This allows the system to find and decode a counter's extension in constant time, directly within the CPU cache.
  • Tails: If a specific cache line becomes too crowded, Sublime offloads the higher-order bits to an external "tails" array.

2. Dynamic Expansion and Contraction

To solve the growth problem, Sublime doesn't stay one size.

  • Expansion: When the total count ($N$) reaches a certain threshold, the sketch doubles its number of counters. By growing the sketch at a rate proportional to $\sqrt{N}$ (or other sublinear functions), Sublime keeps the estimation error sublinear.
  • Contraction: Unlike almost any other frequency sketch, Sublime can shrink. If many items are deleted, it can "fold" itself back down to save memory, maintaining a record of the state to ensure error bounds aren't violated.

Datasets

The researchers evaluated Sublime using several diverse, real-world datasets:

  • Kosarak: 8 million clicks from a news portal (extremely skewed).
  • WebDocs: 300 million words from web documents (moderate skew).
  • CAIDA: 27 million anonymized network traffic 5-tuples (high-speed packet data).
  • TPC-H: A standard 100GB database benchmark used to test join-size estimation.

Key Insights and Ideas

  • Cache Locality is King: The "aha moment" here is co-locating the counter stubs and their extensions within the same 512-bit cache line. This avoids the "pointer chasing" that usually makes variable-length data structures slow in high-throughput streaming.
  • Sublinear is the New Standard: The paper proves a lower bound for expandable sketches, showing that Sublime’s memory footprint is near-optimal for achieving a target error rate on an infinite stream.
  • Unbiased Growth: By applying the Sublime framework to Count Sketch (CS), they created a version that provides unbiased estimates (errors cancel out on average) while still benefiting from adaptive memory.

Key Results

  • Accuracy: SublimeCMS achieved up to 10x lower error than standard CMS and outperformed other "skew-aware" baselines like SALSA and StingyCMS by 40% or more for the same memory budget.
  • Memory Efficiency: In scenarios with deletions, Sublime used 2-3 orders of magnitude less memory than a fixed-size CMS while maintaining higher accuracy.
  • Performance: Despite the complexity of variable-length encoding, Sublime maintained competitive or superior throughput (latency in the tens of nanoseconds) thanks to its bit-manipulation optimizations.
  • Join Estimation: In TPC-H tests, Sublime provided significantly more accurate join-size estimates than traditional sketches, which is critical for database query planners.

Limitations and Future Work

  • Single-Threaded: The current implementation is single-threaded. While the authors outline a strategy for parallelization (using thread-local sketches and periodic merging), it hasn't been fully implemented yet.
  • Beyond Frequency: The authors suggest that the "expandable sketch" philosophy could be applied to other types of data structures, such as those used for estimating cardinalities (HyperLogLog) or quantiles.
  • Encoding Overhead: While VALE is efficient, there is still a small metadata overhead for the overflow bitmaps and delimiters. The authors mention that further compression (like run-length encoding) could save more space but would likely hurt performance.

Summary updated

Abstract

Modern stream processing systems must often track the frequency of distinct keys in a data stream in real-time. Since monitoring the exact counts often entails a prohibitive memory footprint, many applications rely on compact, probabilistic data structures called frequency estimation sketches to approximate them. However, mainstream frequency estimation sketches fall short in two critical aspects: (1) They are memory-inefficient under data skew. This is because they use uniformly-sized counters to track the key counts and thus waste memory on storing the leading zeros of many small counter values. (2) Their estimation error deteriorates at least linearly with the stream's length, which may grow indefinitely over time. This is because they count the keys using a fixed number~of~counters. We present Sublime, a framework that generalizes frequency estimation sketches to address these problems by dynamically adapting to the stream's skew and length. To save memory under skew, Sublime uses short counters upfront and elongates them with extensions stored within the same cache line as they overflow. It leverages novel bit manipulation routines to quickly access a counter's extension. It also controls the scaling of its error rate by expanding its number of approximate counters as the stream grows. We apply Sublime to Count-Min Sketch and Count Sketch. We show, theoretically and empirically, that Sublime significantly improves accuracy and memory over the state of the art while maintaining competitive or superior performance.
BibTeX
@inproceedings{eslami2026sublime,
  author = {Navid Eslami and Ioana O. Bercea and Rasmus Pagh and Niv Dayan},
  title = {{Sublime: Sublinear Error \& Space for Unbounded Skewed Streams}},
  booktitle = {Proceedings of the ACM on Management of Data},
  year = {2026},
  doi = {10.1145/3802116},
}
Figure