Per-generation lists of weak pointers

Akio Takano tkn.akio at
Mon Mar 11 11:17:48 CET 2013


I'm working on implementing per-generation lists of weak pointers to
speed up garbage collection in programs that allocate a lot of weak
pointers. I have a patch [1] that validates and gives a 3x speed up on
a benchmark. However I'd like to ask for some advise before finishing
and submitting the patch.


The problem is that since my patch splits the weak pointer list
between generations, it no longer maintains the right order of weak
pointers. This could cause finalizers added with
addForeignPtrFinalizer to run in the wrong order.

I can think of one way to fix it; to make sure that when a WEAK object
gets promoted, it is always added to the front of the new list. So my
questions are:

- Would it be a correct fix?
- If so, is it an acceptable fix? For example, is it too fragile a
reasoning to rely on?

Thank you in advance,

Takano Akio

More information about the ghc-devs mailing list