Slow code, slow

Rubn where at is.this
Fri Feb 23 21:03:56 UTC 2018


On Friday, 23 February 2018 at 20:52:47 UTC, H. S. Teoh wrote:
> On Fri, Feb 23, 2018 at 08:35:44PM +0000, Rubn via 
> Digitalmars-d wrote: [...]
>> It's not that big of a slow down. Using "fast" you don't 
>> import any modules so they never have to be parsed. That's 
>> pretty much all of phobos you don't have to parse in that 
>> example. That's just the initial cost too. In a big project 
>> this won't make a difference.
>
> Wrong.  This code was reduced from a bigger module (1600+ lines 
> of code) containing the offending function.  If I write that 
> function with a straight loop, the entire module compiles in 
> about 0.4 seconds.  If I change that function to use Phobos 
> algorithms, the compilation time slows down to more than 1 
> second.

I don't know what else you are doing, but if you aren't using 
phobos or any of it's functions in there other than those few 
lines of code. Then yah you'll get the same result.

>> You create a tiny example that is irrelevant to the larger 
>> scale, that takes 0.3 seconds longer to compile.  It's a 
>> magnitude slower cause in your fast example it's literately 
>> only parsing 5 lines of code instead of hundreds of lines like 
>> it is in your slow example.
>
> Please measure before you make statements like that.  You're 
> assuming I wrote that example out of thin air, but it's 
> actually code reduced from a larger module where changing a 
> single function more than doubles the compilation time of the 
> *entire module*.  Parsing is actually extremely fast, esp. with 
> the DMD front end.  The slowdown is caused by the way the 
> compiler handles templates (and possibly the way Phobos uses 
> exponential templates in some places).
>
> And this is only a smaller example of a single module.  I do 
> have code across multiple modules that take horrendously long 
> to compile because of heavy template use.
>
>
> T

I did measure it, adding another instigation of the templates 
using a different type adds a fraction of the time. Not another 
0.3 seconds.




More information about the Digitalmars-d mailing list