Parallel Garbage Collection for Shared Memory Multiprocessors

Christine H. Flood, David Detlefs, Nir Shavit, Xiolan ZhangJava Virtual Machine Research and Technology Symposium 2001

Abstract

As Java applications increasingly migrated to shared-memory multiprocessors in the early 2000s, traditional "stop-the-world" sequential garbage collectors became a significant performance bottleneck. This paper describes a framework for parallelizing garbage collection (GC) by combining static overpartitioning with dynamic work-stealing. The authors successfully parallelized two classic GC algorithms—semispaces and mark-compact—achieving up to a 5.5x speedup on an 8-processor system compared to highly-tuned sequential versions.

Introduction

In the early 2000s, the growth of heap sizes and processor counts in server environments exposed the limitations of strictly sequential garbage collectors. When GC was triggered, all application threads were halted while a single processor performed the cleanup, leading to wasted resources and increased latency. Parallelizing GC is inherently difficult because the workload—tracing the graph of live objects—is unpredictable and cannot be perfectly divided using static partitioning alone.

Parallel Infrastructure and Methodology

The authors developed a parallel GC infrastructure that employs two primary strategies for load balancing:

  1. Static Overpartitioning: For predictable tasks like scanning "roots" or the card table, work is divided into many more subtasks than available processors. Threads then dynamically claim these subtasks. To handle uneven density in card tables, the authors used "strided" partitioning (e.g., Thread A takes cards 0, 8, 16...) to distribute dense reference areas across all processors.
  2. Dynamic Work Stealing: For the unpredictable task of tracing the object graph, the authors implemented a lock-free, double-ended queue. Each thread maintains its own queue of objects to scan; if a thread becomes idle, it "steals" tasks from the top of another thread's queue. This fine-grained approach is essential for handling "lumpy" object graphs.

Parallel Algorithms

The framework was applied to two core algorithms:

  • pSemispaces: A parallel copying collector. To avoid allocation bottlenecks, each thread utilizes Local Allocation Buffers (LABs). Compare-And-Swap (CAS) operations are used to safely install forwarding pointers when multiple threads encounter the same object simultaneously.
  • pMarkcompact: A parallel mark-sweep-compact collector. The heap is divided into $n$ regions. To avoid synchronization during compaction, even-numbered regions slide objects in one direction, while odd-numbered regions slide them in the other, creating large contiguous free areas.
Parallel compaction strategy using region-based partitioning and alternating object movement to maximize free space.

Evaluation and Results

The system was evaluated on a Sun Enterprise 3500 server with eight UltraSPARC processors using three benchmarks: GCOld (synthetic large-heap load), SpecJBB (3-tier system emulation), and Javac (real-world compiler workload).

Performance comparison of sequential (seq) and parallel (par) GC across various benchmarks and processor counts.

The parallel collectors demonstrated strong scalability, achieving speedup factors between 4x and 5.5x on 8 processors for most workloads. Notably, the parallel versions outperformed highly-tuned sequential counterparts on as few as two processors. GCOld saw the highest gains (5.54x speedup for mark-compact), while Javac showed more modest improvements (2.1x) due to its smaller heap size, where the overhead of parallelization and fragmentation was more pronounced.

Discussion and Conclusion

The research highlights that fine-grained, lock-free work stealing is essential for efficient GC, as it allows load balancing at the individual object level with minimal overhead. Furthermore, the study showed that even seemingly sequential phases like compaction can be parallelized through clever partitioning.

However, the use of Local Allocation Buffers introduces some fragmentation, which can increase GC frequency in small heaps. Future work includes adapting more sophisticated sequential optimizations, such as "dense prefix" handling, into the parallel framework to further improve efficiency and reduce redundant work.

Summary updated

BibTeX
@inproceedings{flood2001parallel,
  author = {Christine H. Flood and David Detlefs and Nir Shavit and Xiolan Zhang},
  title = {{Parallel Garbage Collection for Shared Memory Multiprocessors}},
  booktitle = {Java Virtual Machine Research and Technology Symposium},
  year = {2001},
  url = {https://openreview.net/forum?id=Mfkw4SKsgp},
}
Figure