TL;DR
This paper introduces a novel semantic framework and synthesis tool, Pusharoo, that automatically optimizes data pipelines by pushing filtering conditions through complex, stateful User-Defined Functions (UDFs). By framing predicate pushdown as a program verification problem solved via bisimulation invariants, it achieves an average end-to-end execution speedup of 2.4$\times$ across real-world data processing workloads.
What Problem Does This Paper Address?
Modern data-processing pipelines (built on frameworks like pandas or Apache Spark) frequently rely on User-Defined Functions (UDFs) written in general-purpose languages like Python or Scala. These UDFs implement rich domain logic and complex aggregations but are often the most computationally expensive components of the pipeline.
Database systems traditionally use an optimization called predicate pushdown to move data filters as early as possible in a workflow, discarding irrelevant data before it hits expensive operations.
However, existing query optimizers treat UDFs as black boxes. If a UDF maintains an internal state (such as tracking a running top-k list or computing a conditional aggregation), safely moving a filter past it requires deep semantic reasoning. Prior attempts either restricted UDFs to simple stateless operations or required strict mathematical properties like associativity and commutativity. This paper addresses the challenge of automatically synthesizing optimal and provably correct predicate pushdowns for complex, stateful, fold-based UDFs.
Methods
The authors model stateful UDFs as deterministic left folds and introduce a generalized optimization strategy called split pushdown. Instead of completely moving or duplicating a filter, they decompose a post-UDF filter $P$ into a pre-filter $Q$ (applied before the UDF) and a weakened residual filter $P'$ (applied after the UDF).
To guarantee correctness, the authors leverage bisimulation invariants—relational properties that map the internal state of the original pipeline to the state of the optimized pipeline, accounting for rows skipped by the pre-filter.
The core tool, Pusharoo, avoids the combinatorial explosion of searching for these filters and invariants simultaneously through three algorithmic innovations:
- Structured Search Space Decomposition: It enumerates candidate input filters $Q$ in decreasing order of logical strength, transforming a complex three-way dependency (among $Q$, $P'$, and the invariant) into a tractable sequence of subproblems.
- Symbolic Bounds as Unrealizability Certificates: It computes symbolic lower and upper bounds on valid bisimulation invariants. These bounds allow
Pusharooto quickly reject infeasible filter candidates without running a full verification check. - Root-Cause-Guided Repair: If a verification condition fails,
Pusharooanalyzes the SMT solver's counterexample to pinpoint exactly why the filter failed and automatically repairs it.
Datasets
The approach was evaluated on a benchmark suite of 150 data-processing pipelines containing 26 unique stateful UDFs. These benchmarks were sourced from:
- 19 real-world Apache Spark UDFs from prior program-synthesis literature.
- 7 pandas UDFs crawled from GitHub representing complex real-world domain logic (e.g., financial analytics, healthcare, machine learning).
For each UDF, the authors generated 10–20 realistic filtering predicates based on common data-engineering idioms to test various optimization scenarios.
Key Insights and Ideas
- The Power of "Split" Pushdown: Traditional pushdown is binary—either a filter can be pushed entirely or it must be duplicated. The authors realized that you can often weaken the post-filter because the pre-filter already guarantees certain properties, eliminating redundant checks after the UDF executes.
- Decoupling via Invariant Bounds: Jointly inferring a pre-filter, a post-filter, and a correctness proof is a notoriously hard non-Horn constraint problem. By establishing symbolic bounds ($\psi_{min}$ and $\psi_{max}$) on the proof artifact itself, the authors decouple the search, allowing the tool to prune massive chunks of the search space instantly.
- UDFs as Folds: Viewing arbitrary imperative loops in UDFs through the lens of functional left-folds provides a clean mathematical structure that makes relational verification tractable.
Key Results
- Expressiveness:
Pusharoosuccessfully optimized 100% of the 150 benchmarks, whereas the state-of-the-art baseline (MagicPush) could only theoretically handle 14.7% due to its restrictive structural assumptions. - Efficiency: The tool is highly efficient, with a median synthesis time of just 1.6 seconds per benchmark.
- Performance Gains: On datasets of 100 million rows, the optimized pipelines achieved an average end-to-end runtime reduction of 58.8% (a 2.4$\times$ speedup), with extreme cases speeding up by up to two orders of magnitude. Split pushdown alone provided an extra 5.1% speedup over standard partial pushdown by removing redundant post-UDF checks.
Limitations and Future Work
- Finite Predicate Universe:
Pusharoorelies on a heuristically constructed, finite universe of candidate predicates. If an optimal filter or invariant requires complex arithmetic combinations not captured by the initial data-flow analysis, the tool cannot synthesize it. - Pure Fold Restriction: The framework assumes UDFs are pure, deterministic folds. It cannot handle UDFs with side effects (like external I/O or global state mutations) unless those effects are explicitly reified into the accumulator state.
- Future Directions: The authors suggest extending this framework to handle more complex relational operators (like pushing predicates through UDFs that sit inside joins) and exploring automated predicate universe refinement.
Summary updated