Implement runtime flags for accurate residency measurements.
The best way to accuractely establish the maximum heap residency is currently to use
-h -i0 -A<small>. See here.
We can do better.
What we wan't is to measure residency every N bytes, which would limit max residency inaccuracies to
We can get pretty close by that if we use the size of the nursery as N and forcing a major GC everytime the nursery fills up. Which is exactly what
-h -i0 -A<small> does.
However a major GC for
every minor one comes at a large performance cost. Additionally -h causes us to take a heap snapshot adding additional overhead.
Introduce a new Flag
<majorCollectionEveryNMinorCollections>. (Flag name suggestions welcome).
<majorCollectionEveryNMinorCollections> to the RTS we will force a major GC every N minor collections.
If we pass 1 then it has the same effect as
-h -i0 but without the overhead of taking an actual heap snapshot. Limiting residency inaccuracies to
By passing a n > 1 we can still have deterministic accuracy of
n*SizeOfNursery-1 without the cost of turning every minor GC into a major one.
The cost to people not using this feature is neglible, but the benefits to GHC (and Haskell CI in general) would be major.