3 ms·
Wouldn't the GC be able to `munmap` the space between blocks? Sure, it wouldn't solve object-level fragmentation, but at least you'd get rid of block-level fra
by crote 6y ago
Wouldn't the GC be able to `munmap` the space between blocks?
Sure, it wouldn't solve object-level fragmentation, but at least you'd get rid of block-level fragmentation.
- chrisseaton 6y agoYou can only unmap a full page, but there aren’t any full empty pages because the memory is fragmented.
- crote 6y agoAccording to the link, GHC creates 1MiB megablocks, consisting of 4KiB blocks. So, each block would be a page, and a megablock consists of 256 pages. It seems that the problem with pinning is that a megablock will end up containing only a single block, leaving the space for the other blocks unused. The block can't be moved to another megablock because it is pinned, so it can't free the entire megablock. My suggestion is to unmap the pages corresponding to the empty space in the megablock. So if a megablock only contains a single block, unmap the 255 empty pages.
- chrisseaton 6y ago> a megablock will end up containing only a single block That's the absolute worst case. Most likely case is many (most?) pages have one or two pinned objects in them. It only takes a small proportion of pages to be wasted like this for it to be a huge problem.