Bug 21716 – std.regex performance regression (additional GC allocation)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2021-03-15T02:34:23Z
Last change time
2021-04-27T09:42:41Z
Keywords
pull
Assigned to
No Owner
Creator
Jon Degenhardt

Comments

Comment #0 by jrdemail2000-dlang — 2021-03-15T02:34:23Z
I have observed a regex related performance regression my tsv-utils package when switching from LDC 1.24.0 to LDC 1.25.0. This corresponds to a performance regression in DMD 2.095. Mostly likely cause is Phobos PR #7678: https://github.com/dlang/phobos/pull/7678. A possible cause was identified by Petar Kirov in the issue comments (https://github.com/dlang/phobos/pull/7678#issuecomment-787814712): > At first glance, the suspect could be the two new delegates > defaultFactoryImpl and matchOnceImpl. They may or may not > cause GC allocations. If they are replaced with static nested > functions, they would be guaranteed not to cause GC allocations. Checking GC stats using "--DRT-gcopt=profile:1" indicates increased GC in the program: With DMD 2.094.2: > Number of collections: 0 > Total GC prep time: 0 milliseconds > Total mark time: 0 milliseconds > Total sweep time: 0 milliseconds > Max Pause Time: 0 milliseconds > Grand total GC time: 0 milliseconds > GC summary: 5 MB, 0 GC 0 ms, Pauses 0 ms < 0 ms With DMD 2.095.1 > Number of collections: 672 > Total GC prep time: 7 milliseconds > Total mark time: 62 milliseconds > Total sweep time: 7 milliseconds > Max Pause Time: 1 milliseconds > Grand total GC time: 76 milliseconds > GC summary: 5 MB, 672 GC 76 ms, Pauses 69 ms < 1 ms The regular expression used in the tests is '[RD].*ION[0-2]', run against 14 million lines (one invocation per line). It's one of my standard benchmarks. I am investigating further.
Comment #1 by jrdemail2000-dlang — 2021-03-21T09:24:10Z
I have confirmed that Phobos PR #7678 (https://github.com/dlang/phobos/pull/7678) is the cause of the regression. I expect to submit a PR addressing it tomorrow.
Comment #2 by dlang-bot — 2021-03-21T22:27:52Z
@jondegenhardt created dlang/phobos pull request #7902 "Fix issue 21716: std.regex performance regression." fixing this issue: - Fix issue 21716: std.regex performance regression. https://github.com/dlang/phobos/pull/7902
Comment #3 by dlang-bot — 2021-03-22T20:27:25Z
dlang/phobos pull request #7902 "Fix issue 21716: std.regex performance regression." was merged into stable: - 818de5d773abc2eb30da8b401b544db84b46764b by Jon Degenhardt: Fix issue 21716: std.regex performance regression. https://github.com/dlang/phobos/pull/7902
Comment #4 by dlang-bot — 2021-04-25T13:46:00Z
dlang/phobos pull request #7964 "merge stable" was merged into master: - 34e58ec8577375006595201507059024977dc996 by Jon Degenhardt: Fix issue 21716: std.regex performance regression. https://github.com/dlang/phobos/pull/7964
Comment #5 by dlang-bot — 2021-04-27T09:42:41Z
dlang/phobos pull request #8012 "merge stable" was merged into master: - 97a78186ad2fdc24e37325863647eb1db04ad421 by Jon Degenhardt: Fix issue 21716: std.regex performance regression. https://github.com/dlang/phobos/pull/8012