www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18378] New: std.regex causes major slowdown in compilation

https://issues.dlang.org/show_bug.cgi?id=18378

          Issue ID: 18378
           Summary: std.regex causes major slowdown in compilation times
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx


filing this separately as this seems to have been introduced just recently
(merged Aug 2017, though the offending commit itself was earlier).

Code:
------
import std.regex;
void main() {
        string s = `blahblahblah`;
        auto re = regex(s);
}
------

Compilation command:
------
time dmd -c test.d
------

On git master, the timing output is:
------
real    0m3.171s
user    0m2.936s
sys     0m0.233s
------

Which is ridiculously slow for just the mere act of compiling a single regex.

I've managed to isolate the problematic commit to:

(https://github.com/dlang/phobos/pull/5337). There may be other culprits as
well, but this is the major one. Compiling the above code on this specific
commit gives:

------
real    0m2.791s
user    0m2.572s
sys     0m0.218s
------

whereas doing so on the ancestor commit gives:
------
real    0m1.004s
user    0m0.892s
sys     0m0.111s
------

Which is not great, but still 2-3 times faster.

--
Feb 05 2018