Is there a list of things which are slow to compile?

drathier forum.dlang.org at fi.fo
Wed Jun 3 09:36:52 UTC 2020


I'm wondering if there's a place that lists things which are 
slower/faster to compile? DMD is pretty famed for compiling 
quickly, but I'm not seeing particularly high speed at all, and I 
want to fix that.

Currently at ~1ksloc/s of d input without optimizing anything, 
which corresponds to 350ksloc/s if measuring by `-vcg-ast` output 
instead of d source input, while using the same time measurement 
from before, so the flag doesn't cost time.

Here's my learnings so far:
- CTFE is obviously unboundedly slow, since it runs arbitrary code
- Template expansion is presumably O(n) in the size of the 
generated code, and the `-vcg-ast` flag helps a bit to see how 
much it's expanding. I'm not convinced it's the reason my code 
compiles slowly, though.
- no idea how expensive static if's on traits are
- std.regex compiles really slowly
- CTFE always runs on all top-level value definitions (even if 
they contain things which cannot be executed at compile-time, and 
I hate this so so much)

What other things are there?
- identifier lengths?
- comments?
- aliases?
- delegates?
- Variants?


More information about the Digitalmars-d-learn mailing list