Bye bye, fast compilation times

Dmitry Olshansky dmitry.olsh at gmail.com
Tue Feb 6 05:44:17 UTC 2018


On Monday, 5 February 2018 at 21:27:57 UTC, H. S. Teoh wrote:
> One of my D projects for the past while has been taking 
> unusually long times to compile.  This morning, I finally 
> decided to sit down and figure out exactly why. What I found 
> was rather disturbing:
>
> ------
> import std.regex;
> void main() {
> 	auto re = regex(``);
> }
> ------
>
> Compile command: time dmd -c test.d
>
> Output:
> ------
> real    0m3.113s
> user    0m2.884s
> sys     0m0.226s
> ------
>
> Comment out the call to `regex()`, and I get:
>
> ------
> real    0m0.285s
> user    0m0.262s
> sys     0m0.023s
> ------
>

> Clearly, something is wrong if the mere act of compiling a 
> regex causes a 4-line program to take *3 seconds* to compile,

There is a fuckton of templates involved, plus a couple of tries 
are built at CTFE.
The regression is curious though, maybe something gets recomputed 
at CTFE over and over again.

> where normally dmd takes less than a second.

Honestly I’m tired to hell of working with our compiler and its 
compile time features. When it doesn’t pee itself due to OOM I’m 
almost happy.

In retrospect I should have just provided a C interface and 
compiled the whole thing separately. And CTFE could easily be 
replaced by a small custom JIT compiler, it would also work at 
run-time(!).

Especially considering that it’s been 6 years but it’s still is 
not practical to use ctRegex.

> The latter department as also suffered a regression; see for 
> example: https://github.com/dlang/phobos/pull/5981.)
>

Yup, Martin seems on top of it, thankfully.

>
> T




More information about the Digitalmars-d mailing list