Bug 23737 – std.regex is slow to import and use

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-24T13:12:43Z
Last change time
2023-06-16T01:24:54Z
Assigned to
No Owner
Creator
Richard Cattermole

Comments

Comment #0 by alphaglosined — 2023-02-24T13:12:43Z
Right now std.regex is quite slow to import and use. Just importing it alone can add a few hundred milliseconds to your build times. This is most likely linked to std.uni and how it handles its tables decompression. To use a simple regex pattern, adds 1s to your build times, however through some profiling and turning on bootstrap mode in std.uni there are some improvements to be had that will be quite significant. First is the error method inside of Parser struct, remove formattedWrite. Second is to stop trying to memorize the CharMatcher in wordMatcher. For some reason, this adds a lot of time that isn't required. There are more things that can be done, but they don't appear to be big in terms of wins.
Comment #1 by alphaglosined — 2023-02-24T13:25:07Z
https://github.com/dlang/phobos/pull/8698 Only covers the removal of formattedWrite. The problem with wordMatcher is that you actually want it to be memorized, so this particular bit of code is correct and desirable even if it slows down build times significantly, we may want improvements to CTFE engine instead as a solution to it.