SQUID: Faster Analytics via Sampled Quantiles Data-structure

Ran Ben-Basat, Gil Einziger, Wenchen Han, Bilal Tayh

Abstract

Measurement is a fundamental enabler of network applications such as load balancing, attack detection and mitigation, and traffic engineering. A key building block in many critical measurement tasks is q-MAX, where we wish to find the largest $q$ values in a number stream. A standard approach of maintaining a heap of the largest $q$ values ordered results in logarithmic runtime, which is too slow for large measurements. Modern approaches attain a constant runtime by removing small items in bulk and retaining the largest $q$ items at all times. Yet, these approaches are bottlenecked by an expensive quantile calculation method. We propose SQUID, a method that redesigns q-MAX to allow the use of approximate quantiles, which we can compute efficiently, thereby accelerating the solution and, subsequently, many measurement tasks. We demonstrate the benefit of our approach by designing a novel weighted heavy hitters data structure that is faster and more accurate than the existing alternatives. Here, we combine our previous techniques with a lazy deletion of small entries, which expiates the maintenance process and increases the accuracy. We also demonstrate the applicability of our algorithmic approach in a general algorithmic scope by implementing the LRFU cache policy with a constant update time. Furthermore, we also show the practicality of SQUID for improving real-world networked systems, by implementing a P4 prototype of SQUID for in-network caching and demonstrating how SQUID enables a wide spectrum of score-based caching policies directly on a P4 switch.

Introduction

In high-speed stream processing environments, such as those powering Google BigQuery or Apache Spark, systems must frequently track the "top-$q$" most significant items—a fundamental operation known as $q$-MAX. While modern algorithmic approaches aim for constant-time processing per item, they often encounter a performance bottleneck during memory reclamation. To accommodate new data, these systems periodically calculate an exact quantile to evict the smallest items in bulk.

However, calculating an exact quantile is computationally intensive. This challenge is amplified in programmable hardware switches (using the P4 language), which possess massive throughput but limited computational flexibility. These switches cannot easily perform the linear scans or complex sorting required by traditional eviction policies like Least Recently Frequently Used (LRFU).

The SQUID Approach

SQUID (Sampled QUantile EstImation Data-structure) shifts the paradigm from "exact and slow" to "approximate and fast." The core insight is that maintaining a top-$q$ list does not require the exact $q$-th largest item; any item within a "reasonable domain" can serve as a threshold to clear sufficient space.

Comparison between exact quantile calculation in q-MAX and approximate quantile estimation in SQUID.

Sampled Quantiles

SQUID utilizes a "Las Vegas" algorithmic paradigm. Instead of scanning all items, it samples a small subset and selects a pivot. This pivot is then verified: if it retains the top-$q$ items while clearing enough space for new entries, it is accepted. If not, the process retries. This verification step ensures that the algorithm remains 100% correct despite its randomized nature. Furthermore, an adaptive sampling strategy allows the system to stay within user-defined error bounds even when the total stream length is unknown.

Lazy Deletion and the "Water Level"

To eliminate the bottleneck of manual linear scans for deletion, the SQUID-HH (Heavy Hitters) variant employs a "water level" technique. Using a bucket-based data structure, any entry with a value below a global "water level" is treated as logically deleted. This allows the system to overwrite obsolete data lazily during normal operations, avoiding dedicated cleanup phases.

SQUID's bucket-based data structure for efficient weighted heavy hitters tracking.

Hardware-Software Co-design

For P4-enabled hardware, SQUID offloads the pivot calculation to the switch's control plane (CPU) while the high-speed data plane (ASIC) handles packet processing and sampling. This architecture bridges the gap between ASIC speed and CPU flexibility, enabling complex score-based caching policies directly on the switch.

Evaluation and Results

The researchers evaluated SQUID across diverse workloads, including CAIDA internet traces, data center traces (Univ1), and various caching datasets such as Windows server memory accesses and web searches.

Key findings include:

  • Throughput: SQUID achieved up to a 6.6x speedup over state-of-the-art software $q$-MAX implementations.
  • Accuracy: SQUID-HH outperformed alternatives like Elastic Sketch and SMED in both speed and accuracy, measured by Normalized Root Mean Square Error (NRMSE).
  • Cache Performance: In hardware simulations, SQUID-based caching improved hit ratios by up to 16% compared to P4LRU.
  • Efficiency: The control traffic required for SQUID on hardware switches remained minimal, dropping as low as 0.18% for large caches.

Conclusion

SQUID demonstrates that approximate quantile estimation, combined with lazy deletion techniques, can significantly accelerate streaming analytics and enable sophisticated policies on resource-constrained hardware. While the randomized nature of the Las Vegas approach introduces some variability in maintenance time, the performance gains and hardware compatibility make it a powerful tool for modern network measurement and caching. Future work may explore multi-dimensional scoring metrics and further refine arithmetic approximations for specialized hardware.

Summary updated

Abstract

Measurement is a fundamental enabler of network applications such as load balancing, attack detection and mitigation, and traffic engineering. A key building block in many critical measurement tasks is \emph{q-MAX}, where we wish to find the largest $q$ values in a number stream. A standard approach of maintaining a heap of the largest $q$ values ordered results in logarithmic runtime, which is too slow for large measurements. Modern approaches attain a constant runtime by removing small items in bulk and retaining the largest $q$ items at all times. Yet, these approaches are bottlenecked by an expensive quantile calculation method. We propose SQUID, a method that redesigns q-MAX to allow the use of \emph{approximate quantiles}, which we can compute efficiently, thereby accelerating the solution and, subsequently, many measurement tasks. We demonstrate the benefit of our approach by designing a novel weighted heavy hitters data structure that is faster and more accurate than the existing alternatives. Here, we combine our previous techniques with a lazy deletion of small entries, which expiates the maintenance process and increases the accuracy. We also demonstrate the applicability of our algorithmic approach in a general algorithmic scope by implementing the LRFU cache policy with a constant update time. Furthermore, we also show the practicality of SQUID for improving real-world networked systems, by implementing a P4 prototype of SQUID for in-network caching and demonstrating how SQUID enables a wide spectrum of score-based caching policies directly on a P4 switch.
BibTeX
@article{benbasat2024squid,
  author = {Ran Ben-Basat and Gil Einziger and Wenchen Han and Bilal Tayh},
  title = {{SQUID: Faster Analytics via Sampled Quantiles Data-structure}},
  journal = {Proc. ACM Netw.},
  year = {2024},
  doi = {10.1145/3676873},
}

Loading related content...

Figure