Weld: Rethinking the Interface Between Data-Intensive Applications

Shoumik Palkar, James Thomas, Deepak Narayanan, Anil Shanbhag, Rahul Palamuttam, Holger Pirk, Malte Schwarzkopf, Saman P. Amarasinghe, Samuel Madden, Matei ZahariaarXiv 2017

TL;DR

This paper introduces Weld, a novel interface and runtime system designed to optimize data-intensive applications that combine functions from multiple libraries. By using a common intermediate representation (IR) and a lazy evaluation strategy, Weld enables significant performance improvements by minimizing data movement and generating efficient code for diverse hardware, achieving up to 29x speedups.

What Problem Does This Paper Address?

Modern data analytics applications are built by composing functions from various libraries and frameworks (e.g., Spark SQL, NumPy, Pandas, TensorFlow). While individual functions might be highly optimized, the overall application performance is often severely limited by the overhead of moving data between these functions. This "data movement bottleneck" can lead to performance that is orders of magnitude below hardware limits, especially as memory bandwidth struggles to keep pace with processing speeds. Traditional function call interfaces, which rely on materializing intermediate results in memory, exacerbate this problem.

Methods

Weld tackles this challenge with a three-pronged approach:

  1. Functional Intermediate Representation (IR): Weld defines a simple, yet general, functional IR that captures the data-parallel structure of computations. This IR is designed to be amenable to complex optimizations like loop fusion and tiling.
  2. Lazily-Evaluated Runtime API: Libraries submit their computations to Weld using a lazy API. This allows Weld to collect IR code fragments from multiple functions and libraries before execution, building a computation graph.
  3. Optimizer and Hardware Backends: Weld's optimizer then fuses these IR fragments into a single, optimized program and generates efficient machine code for various hardware targets (CPUs and GPUs).

Crucially, Weld can be integrated into existing libraries without altering their user-facing APIs. Libraries can incrementally adopt Weld by porting individual functions.

Datasets

The paper evaluates Weld using standard benchmarks and real-world workloads:

  • TPC-H queries (Q1, Q3, Q6, Q12): Used for evaluating Spark SQL and GPU performance.
  • Black Scholes implementation: A computationally intensive data-parallel workload used for NumPy evaluation.
  • Pandas Cookbook workload: A data science workflow involving filtering, model evaluation, and aggregation.
  • MNIST dataset: Used for evaluating TensorFlow's logistic regression classifier.
  • PageRank: A graph processing benchmark.
  • Nearest Neighbor Classification: Used for GPU evaluation.

No new benchmarks were introduced; instead, existing workloads were adapted to demonstrate Weld's capabilities.

Key Insights and Ideas

  • Data movement is the primary bottleneck: The paper strongly emphasizes that the cost of moving data between independently optimized functions is a more significant performance limiter than the computation itself in many data-intensive applications.
  • Cross-library optimization is essential: Optimizing across the boundaries of different libraries, rather than just within them, unlocks substantial performance gains that are impossible with traditional approaches.
  • Lazy evaluation is key to enabling fusion: By delaying execution, Weld can see the entire computation graph and perform optimizations like loop fusion across library calls, which would be impossible with eager evaluation.
  • A simple, general IR can be powerful: Weld's functional IR, based on nested parallel loops and builders, is expressive enough to capture diverse data-parallel workloads while remaining amenable to sophisticated compiler optimizations.
  • Incremental adoption is feasible: Libraries can benefit from Weld even by porting a small subset of their functions, making adoption less daunting.

Key Results

  • Significant speedups: Weld achieved speedups of up to 29x on applications combining multiple libraries and up to 6.5x on applications using multiple functions from a single library.
  • Cross-library fusion benefits: In a Pandas + NumPy workload, Weld achieved a 29x speedup on a single thread and 187x on 12 cores due to cross-library loop fusion and parallelization.
  • Competitive performance: Weld's generated code was competitive with or outperformed specialized systems like HyPer (for SQL) and GraphMat (for PageRank), and matched TensorFlow's XLA compiler for linear algebra tasks.
  • GPU performance: Weld's GPU backend demonstrated competitive performance, often outperforming CPU backends and matching or exceeding specialized GPU systems.
  • Incremental integration yields benefits: Even porting a single operator in the Black Scholes workload yielded a 1.6x speedup on a single thread.

Limitations and Future Work

  • Single-machine focus: Weld currently targets single-machine, shared-memory environments. Extending it to distributed systems is a direction for future work, though it can be integrated into distributed frameworks like Spark to accelerate local computations.
  • No asynchronous computation: Weld's IR does not support asynchronous computations where threads race to update a result.
  • Debugging challenges: Lazy evaluation can make debugging more difficult, though the authors suggest techniques similar to those used for other lazy systems.
  • Library integration required: Weld's benefits are realized through integration into libraries, which requires some upfront effort.

Future work could explore extending Weld to distributed settings, supporting asynchronous operations, and further refining builder implementations for different hardware.

Summary updated

BibTeX
@misc{palkar2017weld,
  author = {Shoumik Palkar and James Thomas and Deepak Narayanan and Anil Shanbhag and Rahul Palamuttam and Holger Pirk and Malte Schwarzkopf and Saman P. Amarasinghe and Samuel Madden and Matei Zaharia},
  title = {{Weld: Rethinking the Interface Between Data-Intensive Applications}},
  year = {2017},
  eprint = {1709.06416},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1709.06416},
}
Figure