Hyperspecialized Compilation for Serverless Data Analytics

Leonhard F. Spiegelberg, Tim Kraska, Malte SchwarzkopfWorkshops @ VLDB 2023

Introduction

Python has become the lingua franca of data science, yet its execution speed remains a significant bottleneck for large-scale analytics. To bridge this gap, modern frameworks often utilize serverless functions (e.g., AWS Lambda) for massive parallelism, paired with query compilers that translate Python code into efficient machine code.

Traditionally, these frameworks rely on a "one-size-fits-all" global query plan compiled on the client before dispatch. However, this approach ignores data heterogeneity—the reality that schemas evolve and specific data partitions often contain constant values or predictable patterns. This paper introduces "hyperspecialization," a technique where individual serverless functions compile bespoke, highly optimized code paths on the fly based on local data samples.

System Architecture: Viton

The authors developed Viton, a prototype built on the Tuplex framework, to implement hyperspecialization. Viton shifts the paradigm from centralized planning to a distributed, two-phase optimization process.

Viton Architecture: The system splits execution between client-side global planning and Lambda-side hyperspecialization.
  1. Client-Side Global Planning: The client samples cloud storage (S3) to generate a fallback physical plan and sends lightly annotated Abstract Syntax Trees (ASTs) to the Lambdas.
  2. Lambda-Side Hyperspecialization: Each Lambda draws a stratified sample of its assigned data. If the local distribution allows for optimization, the Lambda re-optimizes the AST and uses LLVM to compile a local code path.

Viton leverages two primary speculative optimizations: Constant Folding, which removes code for columns that are constant within a specific chunk, and Filter Promotion, which eliminates redundant checks if a filter condition always passes or fails for a sampled partition.

Performance and Cost Evaluation

The system was evaluated using two heterogeneous datasets: a Flights Dataset (83.51 GB) featuring schema changes over time, and a Github Archive Dataset (35.5 GB) consisting of complex, newline-delimited JSON with frequent API version shifts.

End-to-end query time and cloud compute cost comparison across datasets.

Despite the overhead of running a compiler on short-lived serverless functions, the results demonstrate that hyperspecialization is highly effective. Viton achieved a 3.05× speedup for the Flights query and a 2.27× speedup for the Github query compared to the vanilla Tuplex baseline. Because the execution time was drastically reduced, total cloud compute costs dropped by 2.8× and 2.3× respectively.

Key Insights and Overheads

A critical finding is that compilation on Lambdas is viable if restricted to a specific set of "cheap" LLVM optimizations. In a typical 17.8-second query, Viton spent approximately 2.2 seconds on sampling and compilation overhead. However, the resulting "fast path" code was so efficient that it more than compensated for this initial delay.

By specializing code based on local traits, logical optimizations (like filter pushdown) and compiler optimizations (like dead code elimination) compound. For instance, knowing a filter always fails allows the compiler to strip out massive chunks of parsing logic that would otherwise be executed in a global plan.

Limitations and Future Work

While hyperspecialization offers clear benefits, the authors identify the "specialization unit size" as a key area for future research. Currently, Viton uses individual files, but identifying the optimal subset size to balance compilation overhead against execution speedup remains an open challenge. Additionally, automating the decision of when to perform costly compilation based on expected runtime will be essential for broader adoption in serverless environments.

Summary updated

BibTeX
@inproceedings{spiegelberg2023hyperspecialized,
  author = {Leonhard F. Spiegelberg and Tim Kraska and Malte Schwarzkopf},
  title = {{Hyperspecialized Compilation for Serverless Data Analytics}},
  booktitle = {Workshops @ VLDB},
  year = {2023},
}
Figure