arXiv:2610.18347cs.DSOct 2026

Manuscript Offprint

arXiv:2610.18347

Almost Optimal Relative Error Streaming Quantiles with Full Mergeability

Tomáš Domes, Pavel Veselý

Tomáš Domes D◯\textcircled{D} and Pavel Veselý D◯\textcircled{D}

Computer Science Institute of Charles University, Czech Republic

{domestomas,vesely}@iuuk.mff.cuni.cz

Quantile summaries provide a scalable way to estimate the distribution of individual attributes in large datasets that are often distributed across multiple machines or generated by sensor networks. The state-of-the-art summaries with relative error guarantees of ±ε⋅rank\pm\varepsilon \cdot \text{rank}, offering increasingly higher accuracy towards the distribution's tails, are ReqSketch [Cor+23] and the recent streaming algorithm by Gribelyuk, Sawettamalya, Wu, and Yu [Gri+25]. For inputs of size NN and probability δ\delta of exceeding the error bound, ReqSketch achieves space of O(ε−1⋅log⁡1.5(εN)⋅log⁡δ−1)\mathcal{O}\left(\varepsilon^{-1} \cdot \log^{1.5}(\varepsilon N) \cdot \sqrt{\log \delta^{-1}}\right) memory words, and offers full mergeability, allowing distributed or parallel processing of datasets. In contrast, the latter algorithm exceeds the lower bound of Ω(ε−1⋅log⁡(εN)⋅log⁡log⁡δ−1)\Omega(\varepsilon^{-1} \cdot \log(\varepsilon N) \cdot \log \log \delta^{-1}) from [CV20] only by a factor of O(log⁡ε−1⋅(log⁡ε−1+log⁡log⁡N)⋅log⁡2log⁡δ−1)\mathcal{O}\left(\log \varepsilon^{-1} \cdot (\log \varepsilon^{-1} + \log \log N) \cdot \log^2 \log \delta^{-1}\right), but it lacks the mergeability property, is substantially more involved than ReqSketch, and has unclear practical performance. Both of these data structures consist of relative compactors from [Cor+23] that subsample the stream in a structured way and work well in the streaming setting but are difficult to analyze under mergeability.

We design a new relative-error quantile summary that achieves full mergeability and also improves the state-of-the-art streaming space bound to

O(ε−1⋅log⁡(εN)⋅log⁡log⁡δ−1⋅(log⁡ε−1+log⁡log⁡(εN)+log⁡log⁡δ−1)),\mathcal{O}\left(\varepsilon^{-1}\cdot\log(\varepsilon N)\cdot\log\log\delta^{-1}\cdot(\log\varepsilon^{-1}+\log\log(\varepsilon N)+\log\log\delta^{-1})\right),

which is substantially closer to the lower bound. At the same time, our data structure is simpler than the algorithm from [Gri+25] and therefore more suitable for implementation.

Our technical contribution is twofold: First, we design an adaptive compactor, which improves its state when small items are inserted and is well suited for mergeability, compared to the relative compactor that behaves independently of the incoming items. Second, we design a new space allocation strategy, which assigns capacities to compactors and exploits their adaptivity. While proving the error guarantees is relatively straightforward, the main challenge is in analyzing space requirements, for which we design a new potential-function argument.

1 Introduction

Quantile summaries, or sketches, are data structures of sublinear size, typically just polylogarithmic in the input length, allowing us to efficiently process large streaming or distributed datasets and approximate their distributions by estimating ranks and quantiles. Here, the rank of an item y with respect to S, denoted R(y,S)\mathrm{R}(y, \mathcal{S}), is the number of items in S that are smaller than or equal to y, and quantiles are the inverse of ranks, i.e., a φ\varphi-quantile for φ∈[0,1]\varphi \in [0, 1] is

*Supported by the ERC CZ project LL2406 of the Czech Ministry of Education, Youth and Sports, by grant 24-10306S of GA ČR, and by Center for Foundations of Modern Computer Science (Charles Univ. project UNCE 24/SCI/008).

the ⌈φ⋅∣S∣⌉\lceil\varphi\cdot|\mathcal{S}|\rceil-th smallest input item. Quantile summaries are essential for many applications in network monitoring, e.g., tracking latencies [MRL19; Ten15] or round-trip times [Cor+05], or in sensor networks [Shr+04; He+15].

Many of these applications require two main properties from the summaries that are both challenging to achieve while preserving high space efficiency: First, the quantile summary should provide an accurate distribution approximation, especially for the tails. In particular, network latencies are typically heavily long-tailed [MRL19], and understanding the tail requires increasingly more accurate estimates of the 95th, 99th, 99.5th, etc., percentiles. The notion of relative error captures this scenario by requiring that the rank error for an item of rank RR is at most ε⋅R\varepsilon \cdot R, for an accuracy parameter ε>0\varepsilon > 0; equivalently, for a quantile query φ∈[0,1]\varphi \in [0,1], the summary should return a φ^\hat{\varphi}-quantile, for φ^=(1±ε)⋅φ\hat{\varphi} = (1 \pm \varepsilon) \cdot \varphi. While this yields lower error for items of small rank, high accuracy for the other tail, as desired in monitoring latencies, can be achieved by simply flipping the comparator. A long line of work [GZ03; Cor+05; Cor+06; Zha+06; ZW07; Cor+23] studied relative-error quantile summaries, and recently Gribelyuk, Sawettamalya, Wu, and Yu [Gri+25] developed a randomized streaming algorithm using near-optimal space of O~(ε−1⋅log⁡εN)1\widetilde{O}(\varepsilon^{-1} \cdot \log \varepsilon N)^{1}.

Second, processing the dataset in one pass is, in many cases, infeasible, as it may be distributed across many machines or consist of observations aggregated by sensors [Shr+04]. To allow for distributed or parallel processing of large datasets, the sketch should come with a merge operation that takes two sketches representing datasets S1S_1 and S2S_2 and outputs one sketch representing the multiset union of S1S_1 and S2S_2. A quintessential property of summaries is full mergeability [Aga+13], stating that even when the sketch is built by any sequence of pairwise merge operations on single-item sketches obtained from a set S, its error should be bounded, ideally achieving the same accuracy-space trade-off as in the streaming model. The mergeability setting is more general, since the streaming model can be seen as a repeated merge with a single-item sketch.

The state-of-the-art relative-error and fully mergeable quantile summary is ReqSketch [Cor+23], which consists of a sequence of relative compactors. These are buffers that randomly subsample the stream in a way that facilitates the relative error; see Section 2. ReqSketch has been implemented within the Apache DataSketches library [Rho+13], due to its overall simplicity, mergeability, and fast update time, compared to the widely used t-digest [Dun21; Cor+21].

While ReqSketch [Cor+23] only achieves a suboptimal space bound of O(ε−1⋅log⁡1.5εN)\mathcal{O}(\varepsilon^{-1} \cdot \log^{1.5} \varepsilon N) memory words, the recent improvement in [Gri+25] does not come with any mergeability guarantees (or even a merge operation), and moreover, the new algorithm from [Gri+25] is also significantly more involved than ReqSketch. Indeed, to the best of our knowledge, there is no implementation, and it seems likely that ReqSketch would still perform better than the algorithm of [Gri+25] for data streams in practice.

References (25)