<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 26, 2015 at 5:36 PM, Andrei Alexandrescu via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 7/26/15 10:35 AM, Johan Holmberg via Digitalmars-d wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
On Sat, Jul 25, 2015 at 10:12 PM, Andrei Alexandrescu via Digitalmars-d<br></span><div><div class="h5">
<<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a> <mailto:<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>>> wrote:<br>
<br>
On 7/25/15 1:53 PM, Johan Holmberg via Digitalmars-d wrote:<br>[...]<br>
I download a dmd 2.068 beta, and re-tried with my input file:<br>
now the D<br>
program takes 1.6s (a 10x improvement).<br><br>
Great, though it still seems to be behind the C++ version, which is<br>
a bummer. -- Andrei<br>
[... linux numbers removed ...]</div></div></blockquote>
<br>
I think we should investigate this and bring performance to par. Anyone interested? -- Andrei<br>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Back on MacOS again, I thought I should try to run "Instruments" on my program. I'm not familiar with the DMD source code, but I did the following:</div><div class="gmail_extra"><br></div><div class="gmail_extra">- downloaded the DMD source from Github + built it</div><div class="gmail_extra">- rebuilt my program with this dmd</div><div class="gmail_extra">- used Instruments (the MacOS profiler) on my program</div><div class="gmail_extra"><br></div><div class="gmail_extra">Two things showed up in Instruments that seemed suspicious, both in "stdio.d":</div><div class="gmail_extra"><br></div><div class="gmail_extra">1) calls to "__tls_get_addr" inside readlnImpl" (taking 0.25s out of the total 1.69s according to Instruments). I added "__gshared" to the static variables "lineptr" and "n" to see if it had any effect (see below for results).</div><div class="gmail_extra"><br></div><div class="gmail_extra">2) calls to "std.algorithm.endsWith" inside File.ByLine.Impl.popFront (taking 0.10s according to Intruments). I replaced it with a simpler test using inline code.</div><div class="gmail_extra"><br></div><div class="gmail_extra">The timings running my program normally (not using Instruments now), became as follows with the different versions of dmd:</div><div class="gmail_extra"><br></div><div class="gmail_extra">dmd unmodified: 1.59s</div><div class="gmail_extra">dmd with change 1): 1.33s</div><div class="gmail_extra">dmd with change 1+2): 1.22s</div><div class="gmail_extra">C++ using <stdio.h>: 1.13s (for comparison)</div><div class="gmail_extra"><br></div><div class="gmail_extra">My changes to dmd are of course not correct, but my program still works as before at least. If 1) and 2) could be changed "the right way" the difference to the C++ program would be much smaller on MacOS (I haven't looked further into the Linux results).<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Does this help getting forward?</div><div class="gmail_extra"><br></div><div class="gmail_extra">/johan</div><div class="gmail_extra"><br></div></div>