Re: mmap file performance

2024-04-24 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 15 April 2024 at 16:13:41 UTC, Andy Valencia wrote: On Monday, 15 April 2024 at 08:05:25 UTC, Patrick Schluter wrote: The setup of a memory mapped file is relatively costly. For smaller files it is a net loss and read/write beats it hands down. Interestingly, this performance

Re: mmap file performance

2024-04-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 11 April 2024 at 16:23:44 UTC, Andy Valencia wrote: [...] void main(in string[] argv) ^^ What if you want to use bool memorymapped; getopt (argv, "m", ); inside main? [1] Have you tried using "rm" [2] instead of "r" as stdioOpenmode under Linux for a "no code"

Re: mmap file performance

2024-04-15 Thread Andy Valencia via Digitalmars-d-learn
On Monday, 15 April 2024 at 08:05:25 UTC, Patrick Schluter wrote: The setup of a memory mapped file is relatively costly. For smaller files it is a net loss and read/write beats it hands down. Interestingly, this performance deficit is present even when run against the largest conveniently

Re: mmap file performance

2024-04-15 Thread Patrick Schluter via Digitalmars-d-learn
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.

Re: mmap file performance

2024-04-11 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 11 April 2024 at 14:54:36 UTC, Steven Schveighoffer wrote: For a repeatable comparison, you should provide the code which does 1MB reads. With pleasure: import std.stdio : writeln, File, stderr; const uint BUFSIZE = 1024*1024; private uint countnl(File f) { uint res = 0;

Re: mmap file performance

2024-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn
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.

mmap file performance

2024-04-10 Thread Andy Valencia via Digitalmars-d-learn
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,