memory-mapped files

Lionello Lunesu lionello at lunesu.remove.com
Tue Feb 17 22:35:24 PST 2009


> The memory-mapped version takes 2.15 seconds on average. I was fighting 
> against Perl's equivalent 2.45. At some point I decided to try without 
> memory mapping and I consistently got 1.75 seconds. What the heck is going 
> on? When does memory mapping actually help?

Random seeking in large files :)

Sequential read can't possibly gain anything by using MM because that's what 
the OS will end up doing, but MM is using the paging system, which has some 
overhead (a page fault has quite a penalty, or so I've heard.)

I use std.mmfile for a simple DB implementation, where the DB file is just a 
large,  >1GB, array of structs, conveniently accessible as a struct[] in D. 
(Primary key is the index, of course.)

L. 




More information about the Digitalmars-d mailing list