Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Optimizing garbage collection
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-11-22 (18:38)
From: John Carr <jfc@M...>
Subject: Re: [Caml-list] Optimizing garbage collection

> When everything is smooth, the running time decreases something like
> exponentially with the minor heap size, so you'd always want to
> increase the size.  How do you tell when to stop?  And then, if the
> program is not behaving uniformly, when do you decide to reduce
> the size?

I don't understand "smooth".  Minor heap size should be based on the
rate of garbage generation relative to allocation to balance cache
misses with GC cost.  The ratio may be small or large independent of
whether it varies during the program.

The default minor heap size is well tuned for traditional functional
programming behavior: high rate of allocation, short lifetime.

When memory access is smaller than a cache line the cache does not
reward data reuse so much as address reuse.  Collecting a small minor
heap that is mostly garbage allows the allocator to start over at
an address that is already in cache.  Continuing to allocate instead
of collecting leads to write-allocate misses.