Introduction
In the realm of stream processing, sliding window aggregations—such as calculating the maximum value over the last hour, updated every second—are fundamental operations. For "invertible" functions like sum, these updates are computationally trivial: as the window slides, the system simply adds the new value and subtracts the old one.
However, many critical analytical functions are non-invertible (e.g., max, min, bloom filters). For these, "subtracting" an old value is impossible without potentially re-scanning the entire window, a process that scales linearly ($O(n)$) with window size. While existing algorithms like TwoStack or SlickDeque have improved this, they often suffer from high worst-case latency spikes or fail to leverage multi-core processors for individual aggregation tasks.
The Parallel Boundary Aggregator (PBA)
To overcome these challenges, the authors introduce the Parallel Boundary Aggregator (PBA). The core innovation of PBA is the division of the data stream into "chunks" of slices. For each chunk, the algorithm maintains two independent buffers:
- $csa$ (Cumulative Slice Aggregations): Computed from left-to-right within a chunk.
- $lcs$ (Left Cumulative Slice Aggregations): Computed from right-to-left within a chunk.
The "Aha!" moment of this research is the realization that the $csa$ and $lcs$ buffers required for any given window instance are completely independent. This allows PBA to employ intra-operator parallelism: one thread handles the incoming stream and the $csa$ buffer, while a second thread pre-computes the $lcs$ buffer in the background.
As illustrated in the figure above, when a window reaches a chunk boundary, the $lcs$ buffer is already prepared. The final aggregation then only requires merging at most three partial results, ensuring a worst-case time complexity of $O(1)$. This prevents the system from "stalling" to catch up on a slide, a common issue in prior state-of-the-art algorithms.
Key Results and Performance
The researchers evaluated PBA using real-world manufacturing (DEBS12) and smart home (DEBS14) datasets, as well as synthetic high-volume streams. The results demonstrate significant improvements over existing methods:
- Throughput: For large windows (over 1,000 items), PBA achieved 4x higher throughput than SlickDeque and 2.5x higher than TwoStack.
- Latency: PBA maintained a consistent latency profile (approx. 40-50 nanoseconds for
maxoperations). In contrast, TwoStack showed massive spikes up to 150,000 nanoseconds during internal data reorganization. - Scalability: When integrated into Apache Flink (as FPBA), the algorithm scaled linearly with the number of cluster nodes, proving its readiness for production-grade distributed environments.
For scenarios with very small windows where thread synchronization overhead might outweigh the benefits of parallelism, the authors provide the Sequential Boundary Aggregator (SBA). SBA uses the same chunking logic on a single thread and outperforms other algorithms in low-memory or small-window scenarios.
Limitations and Future Work
While PBA offers a major performance leap, the current model assumes data arrives in order (FIFO). Future iterations may explore tree-based structures to handle out-of-order data more gracefully. Additionally, the researchers plan to investigate multi-query optimization, exploring how PBA might share buffers across multiple queries with varying window sizes or slide intervals.
Summary updated