Hello,
I have a (may be naive?) proposition to improve minor GC, especially with 0Caml 5. Looking at minor_gc.c, which is
a quite complex/long piece of C code, my proposition may be unfeasible because I missed some points
I propose that the minor heap is splitted in two zones: (1) and (2) (beware this is not the usual algorithm for copying generational GC).
- The minor GC does nothing but scanning for (1) and a copying in major/promotion for (2).
- zone (1) and (2) are swapped as soon as zone (1) is full, so allocation is always in zone (1). swap = pointer swap or modification of memory mapping if possible, not copying.
- stop the world minor GC are started when zone (1) and (2) of some domain is full.
- invariant : after a minor GC, zone (2) is always empty and therefore zone (2) is always empty or full.
This seems to have the following advantages:
- the collecting of zone (1) is ultra fast (no copying, just scanning)
- objects are promoted only after one swap meaning much less promotion of short living objects
- domain with slow allocation rate will not promote nothing when zone (2) is empty.
- more object will remain in the minor heap private to each domain (good for immutable object, may be not so
good for mutable ones ?) - as a consequence, the GC should resist well to domain having different allocation pattern
Disadvantage: slow allocating domain will have zone (2) almost never used, wasting half of the minor heap (but they will only promote really long living object). May be adjusting the size of the minor heap dynamically for each domain could be a good idea if one want to save some memory space in that case ?
My 2 scents,
Cheers,
Christophe