NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Space profiling for parallel functional programs

Daniel Spoonhower, Guy E. Blelloch, Robert Harper, Phillip B. Gibbons

Abstract

Parallel functional programming offers significant performance benefits but introduces complex memory management challenges. We present a semantic space profiler that leverages cost semantics to relate runtime resource usage back to source code. By modeling programs as computation and heap graphs, our tool enables developers to reason about the space requirements of different scheduling policies—such as breadth-first versus depth-first—independently of specific compiler implementations. We demonstrate that scheduling choices can have asymptotic effects on memory usage and validate our approach through an implementation in a parallel extension of Standard ML.

Introduction

While parallel execution can dramatically speed up computation, it often leads to "space leaks" or memory spikes that are notoriously difficult to diagnose. In functional languages, the order of task execution—the scheduling policy—dictates the lifetime of immutable data structures. Traditional profiling tools are often too tied to specific runtime systems, making it hard to distinguish between algorithmic space requirements and implementation quirks. This research bridges that gap by providing a formal framework for reasoning about space at the source level.

Methodology: Cost Semantics and Graph Modeling

The core of our approach is a cost semantics framework. Unlike standard semantics, cost semantics quantify the resources required for computation. Our profiler generates two primary structures:

  1. Computation Graphs: Directed acyclic graphs (DAGs) that track control dependencies between tasks.
  2. Heap Graphs: DAGs that track data dependencies, identifying which tasks require specific memory blocks.

By simulating different scheduling policies (e.g., Breadth-First, Depth-First, and Work-Stealing) on these graphs, the profiler calculates the "high-water mark" of memory usage—the maximum live data at any point in time.

Figure 1: (a) Visualization of computation graphs and (b) a comparison of memory usage between breadth-first and depth-first scheduling policies.

Key Insights: Scheduling as a Space Concern

A pivotal finding is that scheduling is not merely a performance optimization but a fundamental space concern. As shown in Figure 1(b), a Breadth-First (FIFO) scheduler can lead to significantly higher memory usage compared to a Depth-First (LIFO) approach. Breadth-first execution tends to keep many intermediate results alive simultaneously, potentially increasing space complexity from linear to quadratic for certain algorithms.

Our framework establishes a "Safe-for-Space" contract. If a language implementation adheres to the cost semantics, programmers are guaranteed that their code will remain within predicted memory bounds across different hardware and schedulers.

Results and Validation

We evaluated our profiler using several classic parallel algorithms, including Matrix Multiplication, Quicksort, Mergesort, Quickhull, n-Queens, and Barnes-Hut. Key findings include:

  • Predictive Accuracy: The profiler accurately identified asymptotic space trends, such as the quadratic space usage in certain parallel Quicksort implementations.
  • Bug Discovery: The tool revealed a real-world space leak in the MLton compiler's "reference flattening" optimization, which unintentionally extended the lifetime of large recursive data structures.
  • Efficiency: Our implementation in parallel Standard ML achieved 60-80% efficiency on 8 cores. We utilized a "restricted allocation" technique in the garbage collector to measure high-water marks with only 10% error and 3x overhead, significantly outperforming full GC-based measurements.

Conclusion and Future Work

Semantic space profiling provides a powerful lens for understanding the memory dynamics of parallel programs. By decoupling algorithmic space needs from runtime implementation details, developers can write more robust, memory-efficient parallel code. Future work will explore integrating task granularity and communication costs into the cost semantics model to better account for modern multicore performance factors.

Summary updated

BibTeX
@inproceedings{spoonhower2008space,
  author = {Daniel Spoonhower and Guy E. Blelloch and Robert Harper and Phillip B. Gibbons},
  title = {{Space profiling for parallel functional programs}},
  booktitle = {ICFP},
  year = {2008},
  doi = {10.1145/1411204.1411240},
}

Loading related content...

Figure