New blog post on the cost of compile time
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 16 15:18:29 UTC 2023
On 1/16/23 4:12 AM, FeepingCreature wrote:
> 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.
>>
>
> 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.
Absolutely, I welcome any improvements that bring the current phobos
into line with the improved version. I would imagine *some* penalty for
ReturnType, regardless of how much can be improved. And of course,
there's the whole question of "is this the right abstraction to use?".
Would there be a better way to write ReturnType that doesn't cost as
much, maybe using CTFE?
I don't know enough about the actual implementation, so its hard for me
to have a productive discussion on it. All I can do is try things and
measure.
-Steve
More information about the Digitalmars-d
mailing list