Optimal and Perfectly Parallel Algorithms for On-demand Data-flow Analysis

Krishnendu Chatterjee, Amir Kafshdar Goharshady, Rasmus Ibsen-Jensen, Andreas Pavlogiannis

Abstract

Static data-flow analysis is a cornerstone of modern compiler optimization and security auditing. However, traditional methods often struggle with the trade-off between preprocessing overhead and query latency. This paper introduces a new algorithm for on-demand data-flow analysis that exploits the inherent "tree-like" structure (low treewidth) of structured programs. By utilizing a lightweight preprocessing phase based on tree decomposition, the proposed method achieves mathematically optimal complexity while enabling perfectly parallelizable queries. Experimental results demonstrate significant improvements in scalability and real-time performance, particularly for Just-In-Time (JIT) compilation scenarios.

Introduction

Static data-flow analysis allows tools to reason about program behavior without execution—answering critical questions like whether a pointer might be null or if a variable is uninitialized. For real-time applications like Just-In-Time (JIT) compilers, on-demand analysis is preferred, as it focuses only on specific variables at specific program points.

Existing on-demand techniques typically face a "Goldilocks problem": no preprocessing leads to slow queries, full preprocessing incurs massive memory costs, and heuristic caching lacks strict worst-case guarantees. This research bridges the gap by providing an algorithm with strict, optimal worst-case guarantees and a minimal memory footprint, making it suitable for high-stakes, real-time environments.

Methodology: IFDS and Treewidth

The authors frame the problem using the Interprocedural Finite Distributive Subset (IFDS) framework, which translates data-flow analysis into a graph reachability problem. The core innovation lies in leveraging the treewidth of control-flow graphs. Because human-written code follows structured patterns (loops, conditionals, functions), these graphs exhibit low treewidth, resembling trees more than random networks. This structural property acts as a "cheat code," allowing the algorithm to bypass traditional complexity limits.

Example of a program and its corresponding Interprocedural Control Flow Graph (ICFG).

The algorithm operates in two distinct phases:

  1. Offline Preprocessing: Instead of computing reachability for all node pairs (which requires $O(n^2)$ space), the algorithm creates a tree decomposition of the program. It precomputes reachability only along the branches of this tree. Efficiency is further enhanced using "word tricks"—packing data into binary sequences to leverage bitwise CPU operations for simultaneous fact processing.
  2. Online Querying: Queries are resolved by checking precomputed tree paths. Because these paths are established during preprocessing, single-source queries can be distributed across multiple CPU threads with zero synchronization overhead, achieving "embarrassing" parallelism.

Experimental Evaluation

The algorithms were evaluated using the DaCapo benchmark suite, covering 22 real-world Java programs and 5 classic data-flow analyses (e.g., liveness, reaching definitions). The test suite included 110 instances with graphs containing up to 190,000 nodes and edges.

Key Results

  • Theoretical Optimality: For analyses with a constant number of data facts, preprocessing time is proportional to the input size $O(n)$, and queries are $O(1)$.
  • Scalability: While traditional Complete Preprocessing (CPP) timed out on graphs with 50,000 nodes, the treewidth-based approach handled 200,000 nodes efficiently.
  • Query Performance: Pair queries consistently completed in under a millisecond, matching the speed of memory-intensive full preprocessing while using drastically less RAM.
  • Parallel Efficiency: On a 12-thread system, the query phase achieved an 11.3x speedup, validating the theoretical claim of near-perfect parallelism in practice.

Conclusion and Future Work

By exploiting the structural properties of programs, this work provides a path toward fast, predictable, and parallel static analysis. While currently limited to same-context queries (where start and end points share the same procedural context), the authors identify the extension to arbitrary interprocedural paths as a primary goal for future research. This approach makes advanced static analysis viable for the strict time constraints of modern JIT compilers and interactive development environments.

Summary updated

BibTeX
@inproceedings{chatterjee2020optimal,
  author = {Krishnendu Chatterjee and Amir Kafshdar Goharshady and Rasmus Ibsen-Jensen and Andreas Pavlogiannis},
  title = {{Optimal and Perfectly Parallel Algorithms for On-demand Data-flow Analysis}},
  booktitle = {ESOP},
  year = {2020},
  doi = {10.1007/978-3-030-44914-8\_5},
}
Figure