Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
San Diego Room
Wednesday, 16:30, 30 minutes
Matthew Hertz, University of Massachusetts Amherst
Emery Berger, University of Massachusetts Amherst
Garbage collection yields numerous software engineering benefits, but its quantitative impact on performance remains elusive. One can measure the cost of conservative garbage collection relative to explicit memory management in C/C++ programs by linking in an appropriate collector. This kind of direct comparison is not possible for languages designed for garbage collection (e.g., Java), because programs in these languages naturally do not contain calls to free. Thus, the actual gap between the time-space performance of explicit memory management and precise, copying garbage collection remains unknown.
We take the first steps towards quantifying the performance of precise garbage collection versus explicit memory management. We present a novel experimental methodology that lets us treat unaltered Java programs as if they used explicit memory management. Our system generates exact object reachability information by processing heap traces with the Merlin algorithm. It then re-executes the program, invoking free on objects just before they become unreachable. Since this point is the latest that a programmer could explicitly free objects, our approach conservatively approximates explicit memory management. By executing inside an architecturally-detailed simulator, this ``oracular'' memory manager eliminates the effects of trace processing while measuring the costs of calling malloc and free.
We compare explicit memory management to both copying and non-copying garbage collectors across a range of benchmarks, and include non-simulated runs that validate our results. Our results quantify the time-space tradeoff of garbage collection: with five times as much memory, the Appel-style generational garbage collector matches the performance of explicit memory management. With only three times as much memory, it runs on average 17% slower than explicit memory management. However, with only twice as much memory, garbage collection degrades performance by nearly 70%. When physical memory is scarce, paging causes garbage collection to run an order of magnitude slower than explicit memory management.