CTFE slower than expected

Jacob Carlborg doob at me.com
Tue May 29 05:10:28 PDT 2012


On 2012-05-29 12:25, Manu wrote:
> I've been trying to work out why my compile times have gone to hell
> recently.
>
> I have a lib, it takes 3.5 seconds to compile.
> I add one CTFE heavy module, it's not huge, certainly much smaller than
> the rest of the app, and it blows out to 18 seconds. I've done some
> experiments removing bits and pieces of code, I can isolate the bits
> that add seconds to the compile time, but the big offenders are one-line
> mixins which use CTFE fairly aggressively to generate the strings they
> mix in.
>
> Can anyone comment on CTFE as implemented? Why is it so slow? It's
> certainly not executing a lot of code. I can imagine executing the same
> routine in an interpreted language like lua would take milliseconds or
> less, not multiple seconds.
> What are the bottlenecks? Is there any way to improve it?

Many small string mixins are slow, even if they're string literals and 
not generated. If possible, it's better with one huge string mixin.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list