Skip to content

Add fragmentation statistics to GHC.Stats

Motivation

Fragmentation is a key statistic when using the non-moving garbage collector. The event log has information about heap fragmentation, but it would be helpful to have the same information available from GHC.Stats.

As far as I understand we can already get at this statistic by taking gcdetails_mem_in_use_bytes - gcdetails_live_bytes . But I'm not sure that's right. And even if that's true, I think it would be more user friendly to make this stat available in an explicit way.

Proposal

Add a field to GHC.Stats.GCDetails called gcdetails_fragmentation_bytes that gives the same stats as the event log fragmentation counter.

I'm happy to implement this.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information