Re: Is Greenspun enough?
- From: Duane Rettig <duane@xxxxxxxxx>
- Date: Thu, 08 Dec 2005 23:29:38 -0800
Ulrich Hobelmann <u.hobelmann@xxxxxx> writes:
> George Neuner wrote:
>>>>> mmap()ed files are also cached, no?
>>>> No. Mapped files are handled by the virtual memory system and all
>>>> modern systems DMA pages directly to/from disk with no buffering.
>>> Seriously? I thought every common OS would buffer/cache most pages
>>> in those files, so it doesn't need to access disk every time
>>> something is read or written (just with normal file reads/writes).
>> Seriously, you need to read up on MMUs, virtual memory and demand
>> paging systems.
>
> Been there, done that. What I (think I) know about modern OSes is
> that they cache everything from disk, I suppose by associating file
> blocks with in-memory-blocks. Surely I could be wrong, but I'd really
> like to know where you got your information that mmap()ed data isn't
> cached at all, because I don't believe it.
The caching sometimes happens at first access, and not at mmap time. It
depends on whether there is backing for the mmap, or if it is
"MAP_NORESERVE", which means that it is using "virtual swap" (which is
different than virtual memory). There is also copy-on-write options
which sometimes create new pages but which don't write them back out - this
allows many processes to map the same file without disturbing the original,
and yet without incurring the extra virtual page cost of a private mapping;
any pages which have not been written to can use the same actual page
across process boundaries.
>
> [... how mmap works; no problems here ...]
>> [IMO, the control offered by mmap() et al. is too coarse grained.
>> Windows file mapping API is easier to use and more flexible.
>> Application level control of the process's virtual memory is one of
>> the few areas where Windows really outshines Unix/Linux.]
>
> Hm, haven't ever looked at the Windows API. I suppose it's both more
> modern in some ways, and more bloated in other ways, than Unix.
I'll speak directly to George about this one; I do have a beef with
one of MS's arbitrary restrictions....
>>> I wager most libraries and maybe even executables on Unix systems
>>> are mmap()ed, so I really can't believe those files aren't ever
>>> cached, but reread from disk on every access...
>> See above.
>
> Which didn't in any way differ from my opinion or understanding of
> mmap(). AFAIK mmapped stuff is written to disk when you modify it,
> but until then it is cached in memory, until the VM system decides to
> drop the pages.
This is also different on different operating systems. We implemented
a memory-mapped file device in our simple-streams implementation which
works for all architectures; you just specify :mapped t as a keyword
pair to cl:open. It keeps mapped data in memory, but the decision as to
when to flush it is made by the mapping strategy; some systems flush
aggressively, and others require a flushing operation (on unix its an
msync() call, and on windows it's a FlushViewOfFile() call). You can see
the difference in behavior by looking at the file in a shell while
having it open in the lisp - if the file contents change when writing is
done, then the flushing strategy is aggressive.
--
Duane Rettig duane@xxxxxxxxx Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182
.
- Follow-Ups:
- Re: Is Greenspun enough?
- From: Rob Warnock
- Re: Is Greenspun enough?
- From: Kostik Belousov
- Re: Is Greenspun enough?
- References:
- Is Greenspun enough?
- From: Greg Menke
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: Ulrich Hobelmann
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: Ulrich Hobelmann
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: Ulrich Hobelmann
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: Ulrich Hobelmann
- Re: Is Greenspun enough?
- From: George Neuner
- Re: Is Greenspun enough?
- From: Ulrich Hobelmann
- Is Greenspun enough?
- Prev by Date: Re: Is Greenspun enough?
- Next by Date: Re: Profiling and Timing
- Previous by thread: Re: Is Greenspun enough?
- Next by thread: Re: Is Greenspun enough?
- Index(es):
Relevant Pages
|
|