How can I use Superpages on an M1 Mac?

I have a number of performance-intensive tasks that I need to run regularly, such as compiling and linking large programs, and I'd like to see if superpages are of help here. I've had great long-term success with low-level changes to other aspects of the programs, such as the malloc default zone, and would like to see if changing the page size can provide similarly fruitful results. There is some evidence that that may be the case (https://easyperf.net/blog/2022/09/01/Utilizing-Huge-Pages-For-Code#option2-remap-the-code-section-at-runtime and https://xmrig.com/docs/miner/hugepages). However, when I try, mmap(NULL, 2 * 1024 * 1024, PROT_READ, MAP_ANON | MAP_PRIVATE, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0) for example, it always fails. Is there any way to use superpages?

  • See paper: https://llvm.org/pubs/2009-03-ACMSE-Superpage.pdf

  • @MobileTen I've responded in a reply

Add a Comment

Replies

@MobileTen that paper appears to simply say that compilers should add the mmap call in implicitly to get applications to automatically use superpages, but it doesn't actually discuss how to do the call