Conversation

I'd strongly recommend measuring the size of the address space and reserving a huge portion as a massive PROT_NONE mapping rather than using hints though. mmap hints aren't respected everywhere and you can end up with other mappings getting in the way and screwing up the hints.
2
3
I mean, if this is linux then you could just skip some steps by doing the massive mmap, make it all rw, and then only touch a page when you want the kernel to allocate a page for it. There will be a bit of read ahead but Linux’s allocation uses an “optimistic” strategy.
1
It won't work well in the default heuristic overcommit mode which gives you the worst of both worlds. It only works properly in the full overcommit mode. Linux has support for a memory accounting mode too, and it doesn't work for that, since rw anon memory is accountable.
2
1
Show replies
Show replies