MADV_HUGEPAGE on nursery
Motivation
An application compiled by GHC will use the nursery frequently. Not only that, it will touch almost every address in the nursery, and it should never be swapped out to disk. Consequently, it is an excellent candidate for hugepages. This is true whether the nursery is the tiny default 1MB or the 128MB monster that people use when trying to get better performance on many-core hosts.
Proposal
Add an RTS flag --nursery-advise-hugepage
. This flag, when set, would cause the runtime to advise operating systems that support transparent hugepages that the nursery is a good candidate:
madvise(nursery_ptr, nursery_size, MADV_HUGEPAGE);
I'd like to try this out when I have some time, but I wanted to write this down here in case I forget about it. I suspect that the benchmarks likely to benefit from this would be things with larger nurseries (that don't fit in cache). It also would have to be something that runs for a while. I don't know how long the kernel takes to decide to use hugepages.