Bye bye, fast compilation times

Martin Tschierschke mt at smartdolphin.de
Thu Feb 8 11:21:28 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, 
> where normally dmd takes less than a second.
>
Thank you for this finding!

I was wondering why my little vibe.d project started to take 
approximately twice the
time to compile, and because of making a mistake in my test 
setup, even my minimal
program still included the file containing the regex. So that 
even reducing the used
code to a minimum the compilation time was ~7 sec compared to 
less than 4 seconds.

Would be cool if we could get fast compilation of regex.

I am coming from using scripting languages (perl and ruby) using 
regex a lot, so that this is really disappointing for me.

Beginner question:
How to split my project, to compile the regex part separately as 
a lib and just link them?



More information about the Digitalmars-d mailing list