[mercury-users] Structure reuse

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jul 15 12:39:20 AEST 2003


On 15-Jul-2003, Michael Day <mikeday at yeslogic.com> wrote:
> 
> [Ralph wrote:]
> > I believe the heap is checked for sufficient space on each allocation.
> > If there is insufficient space then garbage collection occurs.  GC
> > traverses the entire set of live data, so one does not want to do this 
> > too frequently (e.g. after every few allocations.)  Having garbage lying
> > around should not affect your program's performance, other than possibly
> > causing more CPU cache misses.  It's the size of the working set that is
> > important, not the size of the heap.
> 
> Hmm, what happens to garbage on the heap that has not yet been reclaimed,
> when the heap does not fit into real memory? Will it be swapped out? When
> the garbage collector runs, will it be swapped back in to be traversed?

Yes and yes.  However, with the Boehm collector, the ratio of garbage
on the heap to live data is essentially fixed (although you can
alter this by setting the C variable GC_free_space_divisor).  What varies
is the frequency of collections.  Creating more garbage doesn't increase
the size of the heap, it just increases the frequency of collections.

> Basically, will the current behaviour lead to unnecessary page faults and
> thrashing as well as CPU cache misses, when the heap contains a lot of
> garbage that could have been reclaimed earlier?

Allocating unnecessary garbage will not increase the size of the heap,
so it will not of itself lead to thrashing; but, if your application is
already thrashing, allocating unnecessary garbage will make the
thrashing worse, since you'll do more frequent garbage collections,
and each garbage collection will touch the entire heap.

Allocating unnecessary garbage will almost certainly lead to additional
cache misses.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list