Is there any reasons to not use "mmap" to read files?

Temtaime temtaime at gmail.com
Sun Feb 6 10:53:49 UTC 2022


On Sunday, 6 February 2022 at 10:48:01 UTC, rempas wrote:
> On Sunday, 6 February 2022 at 10:08:24 UTC, Elronnd wrote:
>> Performance is weird, and depends a lot on your access 
>> patterns and constraints.  Mmap is not universally fast and, I 
>> would argue, really only makes sense in a few constrained 
>> circumstances.  I would not switch to mmap just because you 
>> heard it was faster; only consider switching if you know i/o 
>> is a bottleneck for your application and know mmap is the 
>> solution.
>>
>> https://db.cs.cmu.edu/papers/2022/cidr2022-p13-crotty.pdf  
>> recent, good read.
>
> Thank you! I will actually make a compiler so it will just open 
> and read the requested files. I don't know if the database 
> example you linked will be similar to my case (I will of course 
> read it tho) so I have to make my research I guess just to be 
> sure.

Perso i'm almost always use mmap for opening large files for r/w. 
It IS faster.
Exception are small ones that can be read into the memory using 
std.file.read for example.


More information about the Digitalmars-d mailing list