mmap file performance

Steven Schveighoffer schveiguy at gmail.com
Thu Apr 11 14:54:36 UTC 2024


On Thursday, 11 April 2024 at 00:24:44 UTC, Andy Valencia wrote:
> I wrote a "count newlines" based on mapped files.  It used 
> about twice the CPU of the version which just read 1 meg at a 
> time.  I thought something was amiss (needless slice 
> indirection or something), so I wrote the code in C.  It had 
> the same CPU usage as the D version.  So...mapped files, not so 
> much.  Not D's fault.  And writing it in C made me realize how 
> much easier it is to code in D!

For a repeatable comparison, you should provide the code which 
does 1MB reads.

I have found that mmapped files are faster than reading buffered 
files, but maybe only for large files?

-Steve


More information about the Digitalmars-d-learn mailing list