Skip to content

IntTable can lead to large amount of fragmentation

GHC.Event.IntTable uses a ForeignPtr Int to store the size of the table. This is bad because a lot of very small pinned bytestrings end up allocated which causes a significant amount of fragmentation. In my benchmark there were about 250 of these tables allocated which led to an additional 25 megablocks being retained.

https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/base/GHC/Event/IntTable.hs#L38

Locally I changed this to use an IORef, which significantly improved fragmentation in my benchmark because it no longer uses pinned memory. Is that the right fix?

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