So, apropos of my last post, I'm curious whether there's been any work/research/proposal on ways to enhance memory-mapping to address some of the problems Michael brought up. (I mean in any OS, not just Darwin.)
Just off the top of my head, I think it would be very useful to have a call to say "I want to use this address range", which would page that part of address space into RAM or return an error if it failed. This would help with both the reliability issue, since you could preflight memory accesses and back out if it fails, and the performance issue, since you could read a large block in one I/O. The obvious problem is that it's racey. The paged-in memory is available for eviction, so you can't guarantee that by the time you get around to accessing a particular page in that range it hasn't already been paged out, incurring another possibly-failing I/O call to read it again. Not sure what to do about that. If you make it into a begin/end pair of calls, then the in-use pages either have to be wired into RAM, which is bad, or given temporary space in a swap file, which seems pretty complex. (But I know nothing about the innards of the VM system...)
Apologies if any of this is obviously idiotic to one skilled in the art. But I've been tinkering with an experimental nonrelational database engine that uses mmap for I/O, so these issues have been rattling around in my brain for a while.
—Jens |