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
caml_oldify_local_roots takes 50% of the total runtime
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-26 (13:48)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] caml_oldify_local_roots takes 50% of the total runtime
Am Donnerstag, den 26.10.2006, 05:01 +1000 schrieb skaller:
> On Wed, 2006-10-25 at 14:21 -0400, Markus Mottl wrote:
> > It would be great if the GC could be improved in situations where
> > there are many local roots.  This is a pretty common problem when
> > interfacing non-trivial third party libraries, and the clumsy
> > workarounds require writing somewhat error-prone code. 
> Just curious .. but why is there *ever* any need for more than
> one root? If you need to add a root, why not just add to
> an already rooted data structure? Would that solve the problem?

Yes, that solves it. The point is that a normal data structure (e.g.
hash table, ...) can be moved to the major heap, so it is only traversed
for each major collection.

Note also that there are local and global roots. You need local roots
for every pointer that is _temporarily_ outside the heap, so yes, you
need usually a lot of them. Pointers on the stack are local roots, too.

Global roots are for pointers that are outside the heap for a long time.
I think these could be handled more efficiently by the GC, e.g. by
moving global roots to a second list when the object referenced by the
pointer is moved to the major heap.

Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
Phone: +49-6151-153855                  Fax: +49-6151-997714