Disappointing performance from DMD/Phobos

David Bennett davidbennett at bravevision.com
Tue Jun 26 03:23:45 UTC 2018

On Tuesday, 26 June 2018 at 02:10:17 UTC, Manu wrote:
> [snip]
>   @property uint systemBits() const { return 
> systemData[].map!(e =>
> e.length).sum; } [snip]
> This property sum's 4 ints... that should be insanely fast. It 
> should
> also be something like 5-8 lines of asm.
> Turns out, that call to sum() is eating 2.5% of my total perf
> (significant among a substantial workload), and the call tree 
> is quite
> deep.
> Basically, inliner tried, but failed to seal the deal, and 
> leaves a call stack 7 levels deep.

Last time I checked, dmd's inliner would give up as soon as it 
sees any type of loop, even the simplest while loop... then the 
unroller and optimiser later on have less to work with.

So I would expect it's the loop in `sumPairwise()` [0] or 
`sumKahan()` [1] that's the main source of your problems.

If we could get that to inline better using `dmd -inline` it 
would probably speed up quite a lot of code.


More information about the Digitalmars-d mailing list