www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - byLine and readln performance with LDC

reply Jon D <jond noreply.com> writes:
I'm seeing dramatically slower runtime performance using byLine 
and readln when compiling with LDC than with DMD. Has anyone seen 
this behavior?

Example:

import std.stdio: File, KeepTerminator, writeln;

void main(string[] args) {
     if (args.length != 2) {
         writeln("Provide exactly one filename");
         return;
     }

     auto inputStream = args[1].File();
     size_t lc = 0;
     foreach (line; inputStream.byLine(KeepTerminator.yes)) {
         ++lc;
     }
     writeln(lc);
}

Using a 1.7gb, 37 million line file:
  - ldc2 (-release -O):  37 seconds
  - dmd (-release -O):   4 seconds

Same results with readln rather than byLine.  However, byChunk is 
fast, even with small chunks like 40 bytes.

This is using:  Mac OS X (10.10.5);  DMD 2.068; LDC 0.16.1

--Jon
Dec 08 2015
parent reply Kagamin <spam here.lot> writes:
LDC 0.16.1 is based on DMD 2.067.1
Dec 09 2015
parent Jon D <jond noreply.com> writes:
On Wednesday, 9 December 2015 at 08:43:03 UTC, Kagamin wrote:
 LDC 0.16.1 is based on DMD 2.067.1
Ah, this enhancement: https://issues.dlang.org/show_bug.cgi?id=11810. Thanks, that's a rather significant optimization.
Dec 09 2015