4 ms·
I read it to mean mmap is irreplaceable. There is no other sophisticated dance of system calls or userspace trickery that can achieve what mmap can achieve. She
by dundarious 4y ago
I read it to mean mmap is irreplaceable. There is no other sophisticated dance of system calls or userspace trickery that can achieve what mmap can achieve. She's saying that everything up and down the stack, including high level libraries, do just call mmap, because there would be no DIY alternative with similar cost-benefit.
- 10000truths 4y agoExcept it’s not irreplaceable, at least on Linux. userfaultfd allows you to define custom page fault handling. With it, you can even do crazy things like “mmap” a remote resource by making HTTP range requests on a read fault.
- lostmsu 4y agoIs there anything like that on Windows?
- astrange 4y agoYes, it's how JITs like Java work. Though I don't specifically know what the Windows API is.
- lostmsu 4y agoThis has nothing to do with JITs. JITs just have a stub trampoline. Some garbage collectors do have page tracking though.
- 10000truths 4y agoWindows has vectored exception handlers, which are a bit like UNIX signal handlers but much more sanely designed. You can use that to redirect control flow when a page fault occurs, and you can check the faulting address in your handler to scope it to a particular region of memory.
- dundarious 4y agoYou’re right. Irreplaceable was a stronger way of putting it than the original, I think, so that’s more my mistake than hers, and I think the contrast with userspace stands. mmap sits at this lovely intersection between virtual memory and the disk, and it’s been around for a long time. By now there are other means of playing within that nice intersection, but mmap is the pop classic.
- deleted 4y ago[deleted]