200-600x slower Dlang performance with nested foreach loop

methonash nope at dne.com
Tue Jan 26 18:13:54 UTC 2021


On Tuesday, 26 January 2021 at 17:56:22 UTC, Paul Backus wrote:
>
> It would be much easier for us to help you with this if you 
> could post the full program, or at the very least a reduced 
> version that reproduces the same issue. [1] Since your attempts 
> so far have failed to fix the problem, it is quite likely that 
> some part of the code you do not suspect is actually to blame.

I cannot post the full source code.

Regarding a reduced version reproducing the issue: well, that's 
exactly what the nested foreach loop does. Without it, the 
program reaches that point quickly.

With the nested foreach block, it slows to a crawl. More 
specifically, commenting-out the indexOf() or countUntil() 
sub-blocks preserves fast performance, but I'm not sure if that 
may be related to compiler optimizations realizing that there's 
nothing but "dead/nonexistent code" inside the loops and 
generating a binary that just never goes there.

If this may help: I've composed the second Dlang implementation 
as one extended block of code within main() and am thinking of 
soon refactoring the code into different functions. I remain 
pessimistic of whether this may help.

Is there any possibility this could be GC-related?


More information about the Digitalmars-d-learn mailing list