New blog post on the cost of compile time

FeepingCreature feepingcreature at gmail.com
Mon Jan 16 09:12:59 UTC 2023


On Monday, 16 January 2023 at 04:30:25 UTC, Steven Schveighoffer 
wrote:
> In this post: 
> https://forum.dlang.org/post/tm3p0p$2js2$1@digitalmars.com
>
> I mentioned:
>
>> I did a test on something I was working on for my talk, and 
>> I'm going to write a blog post about it, because I'm kind of 
>> stunned at the results.
>
> Well, I finally got around to it:
>
> https://www.schveiguy.com/blog/2023/01/the-cost-of-compile-time-in-d/
>
> Let me know what you think.
>
> -Steve

Looks like :handwaves: given a 2.4Ghz processor, that'd be 150k 
cycles per ReturnType instantiation? Not super much, but not 
nothing either. If that distributes over five templates, it'd be 
something like 30k for a template instantiation in general. For 
something that hits the allocator a few times, that seems ... 
about right?

Indicating to me that if we want this to be fast, we have to find 
a way to make a template instantiation *do less.* I think that's 
gonna be a hard sell, given that the instantiation absolutely has 
to make a copy of the entire template body AST given the compiler 
design as it is.

Looking at a profiler, how would you say these cycles are 
distributed between "copy tree" and "walk tree for semantic"?


More information about the Digitalmars-d mailing list