Blog post revives 'two-stack' algorithm for sliding-window aggregation
A developer's blog post explains a 'two-stack' method for computing sliding-window aggregations—such as minimum, maximum, or quantiles—that works even when the aggregation operator has no inverse. The technique, drawn from a paper by Tangwongsan et al. on low-latency sliding-window aggregation, achieves amortized constant-time updates using two stacks instead of a double-ended queue, and the author says it renders their own earlier six-year-old min/max algorithm obsolete.
GoKawiil's interpretation of the reporting above, not reported fact.
Many practical streaming aggregations, like floating-point sums, approximate counts, or percentile tracking, cannot be computed with the simple invertible-operator trick used for basic running sums, so a general method matters for real-time monitoring and analytics systems. The author argues this broadens the class of problems that can be solved efficiently without resorting to more complex worst-case constant-time algorithms, suggesting it could become a more widely adopted building block for streaming data pipelines.
- The two-stack algorithm supports sliding-window aggregation for operators without inverses, such as min, max, and quantiles.
- It achieves amortized O(1) performance, contrasting with a more complex worst-case O(1) algorithm from a related academic paper.
- The author considers it a simpler alternative that could replace specialized solutions like their own earlier min/max-specific algorithm.
Source: orlp.net, 2026-10-13
Published there as: “Two-Stack Sliding-Window Aggregation”
Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.