A Common Runtime for High Performance Data Analysis

Shoumik Palkar, James Thomas, Anil Shanbhag, Deepak Narayanan, Holger Pirk, Malte Schwarzkopf, Saman P. Amarasinghe, Matei Zaharia

Abstract

Modern data analytics workflows often combine multiple specialized libraries like Spark, NumPy, and TensorFlow. While efficient individually, these libraries act as "black boxes" to one another, leading to a significant "data movement bottleneck" where data must be materialized in memory to cross library boundaries. Weld is a high-performance runtime that addresses this by using a common functional intermediate representation (IR) and lazy evaluation to enable cross-library optimizations. Weld delivers speedups of over 30x in some cases without requiring changes to existing user code.

Introduction

Historically, data processing was centralized within Relational Database Management Systems (RDBMS) that could optimize applications end-to-end. Today's data science landscape is fragmented; practitioners use a disparate mix of libraries—Spark for SQL, NumPy for linear algebra, and TensorFlow for machine learning.

The primary challenge is that these libraries are mutually opaque. When data moves from a Spark query into a NumPy array, it must be materialized in memory. In data-intensive workloads with low computation per byte, this constant data movement becomes the primary performance bottleneck. Research shows that even highly optimized frameworks can be 10–30x slower than hand-tuned code because they cannot optimize across these library boundaries.

The Weld Architecture

Weld is designed to bridge these gaps through three core components:

  1. Common Intermediate Representation (IR): Weld utilizes a minimal, functional IR based on parallel loops and "Builders." Builders are declarative data types (e.g., vecbuilder, merger) that define how results are constructed in parallel without specifying the underlying implementation.
  2. Lazy Evaluation API: Instead of immediate execution, Weld-enabled libraries produce IR fragments. The runtime collects these into a Directed Acyclic Graph (DAG), optimizing and executing the entire workflow only when an evaluation is forced (e.g., by a print statement).
  3. Optimizing Compiler: Weld performs "whole-workflow" optimizations on the combined IR. A critical optimization is loop fusion, which maintains data in CPU registers or cache across operations, avoiding costly RAM writes. The backend leverages LLVM to generate machine code that automatically leverages Intel AVX2 vectorization and multi-threading.
The Weld runtime architecture and optimization flow.

Weld also employs linear types for Builders, ensuring each is consumed exactly once. This allows the backend to safely use efficient, mutable state internally while maintaining a functional external interface.

Performance Evaluation

The authors evaluated Weld across SQL (TPC-H), Graph Analytics (PageRank on twitter_rv), Machine Learning (Logistic Regression and Word2Vec on MNIST), and real-world data cleaning tasks (Pandas).

Performance comparison of Weld against specialized frameworks and hand-optimized code across various workloads.

Key Results

  • Significant Speedups: Integrating Weld provided a 6x speedup for Spark SQL, 32x for TensorFlow, and 30x for Pandas.
  • Cross-Library Optimization: In an application combining Spark SQL and a Scala UDF, Weld achieved a 14x speedup by fusing the UDF into the query's scan loop.
  • Competitive Performance: Weld's generated code matches or exceeds the performance of state-of-the-art specialized systems like HyPer for SQL and GraphMat for graph processing.
  • Ease of Integration: Major frameworks were integrated with Weld using only a few hundred lines of "glue code," demonstrating its practicality for existing ecosystems.

Discussion and Future Work

The "Data Movement Wall" is a growing concern as the gap between processor speed and memory bandwidth widens. Weld's "Aha!" moment is the realization that diverse workloads share a common parallel structure that can be abstracted into "Builders." This allows for incremental adoption; Weld can be integrated as a backend optimization while leaving user-facing APIs untouched.

However, limitations remain. The current IR is deterministic and cannot yet express asynchronous algorithms like Hogwild!. Additionally, the prototype does not yet manage NUMA locality or target heterogeneous hardware like GPUs and FPGAs, though its parallel IR makes it a strong candidate for such future extensions. As the IR evolves to support more complex structures, the authors anticipate the need for more sophisticated cost-based optimizers.

Summary updated

BibTeX
@inproceedings{palkar2017common,
  author = {Shoumik Palkar and James Thomas and Anil Shanbhag and Deepak Narayanan and Holger Pirk and Malte Schwarzkopf and Saman P. Amarasinghe and Matei Zaharia},
  title = {{A Common Runtime for High Performance Data Analysis}},
  booktitle = {CIDR},
  year = {2017},
}
Figure