As well as mmap() + huge pages, we could support TCMalloc + huge pages. I believe TCMalloc will support this well because:
- We can allocate huge-page-aligned memory via posix_memalign()
- TCMalloc, by default, always decommits large allocations upon freeing them. So if we undo the HUGEPAGE madvise() before handing the pages back to TCMalloc, then TCMalloc will decommit the huge pages backing the allocation, and we won't get TCMalloc's page heap into a weird state.
This could give us the perf benefits of huge pages without some of the headaches associated with using mmap() directly.