[Gc] Performance improvements

Boehm, Hans hans.boehm at hp.com
Tue Jul 12 17:40:09 PDT 2005

> From: Juan Jose Garcia Ripoll
> With this in mind, up to now I have taken these steps:
> + set GC_no_dls=1
> + create a custom function for GC_push_other_roots which marks all
> static data in ECL
You should also call GC_clear_roots after initializing the collector
(e.g. with GC_INIT()) to avoid tracing the main data segment.

> The problems I have found are
> 1) GC_no_dls has no effect in the Mac OSX port. I had to 
> change the file gc/dyn_load.c in the following way so as to 
> prevent registering the static data from dynamically linked libraries.
> static void GC_dyld_image_add(struct mach_header* hdr, unsigned long
> slide) {
>     unsigned long start,end,i;
>     const struct section *sec;
>     if (GC_no_dls) /* My change! */
> 	return;
That looks like a bug to me.  I propagated your change to my source
> 2) I have regions of memory which I use for stacks in the 
> interpreter. Typically only a percentage of this regions 
> contains pointers, while the rest should be discarded. Until 
> now I was using something like 
>  GC_push_conditional((ptr_t)env->stack, 
> (ptr_t)env->stack_top, 1);  GC_set_mark_bit((ptr_t)env->stack);
> However, in experiments with the latest garbage collector 
> (v.6.5) I found that even the region above env->stack_top is 
> scanned for pointers. I have changed the interpreter so that 
> env->stack is allocated with
> GC_malloc_atomic() but I am unsure about this change.
Presumably you call GC_set_mark_bit only if you allocate the
stack dynamically?

Either way it should be OK (GC_malloc_atomic, setting mark bit,
or statically allocating it, not setting it).  This may have had
to do with the missing GC_clear_roots() call.  If not, it would
be good to understand why the rest of the stack was getting scanned.
It shouldn't have been.

If the stack may contain compiler temporaries, like a native stack,
it would be safer to use GC_push_all_stack.
> 3) It would be useful to have either a runtime or 
> configuration flag to make the Boehm-Weiser garbage collector 
> less conservative: i.e. impose that the user should supply 
> all roots, except for the stacks, which would be scanned 
> conservatively. I could code this myself, but I am not very 
> comfortable with the inner guts of the collector. Also, I 
> think this is a useful extension from which other 
> interpreters or compiled environments could profit.
I completely agree.  It's on my list ...


More information about the Gc mailing list