memory-mapped files
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Feb 18 15:45:44 PST 2009
Brad Roberts wrote:
> bearophile wrote:
> >> What the heck is going on? When does memory mapping actually help?<
>> You are scanning the file linearly, and the memory window you use is
>> probably very small. In such situation a memory mapping is probably
>> not the best thing. A memory mapping is useful when you for example
>> operate with random access on a wider sliding window on the file.
>
> You can drop the 'sliding' part. mmap tends to help when doing random
> access (or sequential but non-contiguous maybe) over a file. Pure
> streaming is handled pretty well by both patterns. One nicity with mmap
> is that you can hint to the os how you'll be using it via madvise. You
> can't do that with [f]read.
Hey Brad,
Nice advice on madvise, didn't know about it. Just in case it might be
useful to someone, trying madvise with any of the four possible policies
did not yield any noticeable change in timing for my particular test.
Andrei
More information about the Digitalmars-d
mailing list