Bug 19550 – [REG 2.078] Massive compiler backend slowdown

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-01-04T17:11:34Z
Last change time
2021-04-09T19:08:52Z
Keywords
pull
Assigned to
No Owner
Creator
Iain Buclaw
See also
https://issues.dlang.org/show_bug.cgi?id=6401

Attachments

IDFilenameSummaryContent-TypeSize
1781patch19550.diffpreliminary patchtext/plain579

Comments

Comment #0 by ibuclaw — 2019-01-04T17:11:34Z
Test case: --- # timeout 5 dmd -O bug.d struct Buf { char[7_000] buffer = void; } void main() { uint len; auto b = Buf(); b.buffer[len] = 'a'; } --- In case you thought that the timeout of 5 seconds is too short, I compared build times of the two releases in full. Compiler | Build time ---------------------- 2.077.1 | 0m0.527s 2.078.0 | 1m3.694s
Comment #1 by ibuclaw — 2019-01-04T17:15:21Z
Comment #2 by ibuclaw — 2019-01-04T17:20:00Z
Commenting out the call to blassertsplit() fixes this issue.
Comment #3 by bugzilla — 2019-01-05T08:40:25Z
Comment #4 by bugzilla — 2019-12-12T10:28:28Z
This bug is still there.
Comment #5 by safety0ff.bugz — 2020-04-29T01:57:33Z
I ran the test code through callgrind and `accumaecpx` gets called 6.155 million times. Adding issues #6401 and #7157 to the see also list.
Comment #6 by safety0ff.bugz — 2020-04-29T17:02:29Z
Ok I believe to have found the culprit: There is a special case for OPcomma here, which traverses the entire list of elems: https://github.com/dlang/dmd/blob/793635ea7ad3cf30c02bf1b5d51eefdc166c8b82/src/dmd/backend/gflow.d#L624 But `accumaecpx`already recurses over the list of elems: https://github.com/dlang/dmd/blob/793635ea7ad3cf30c02bf1b5d51eefdc166c8b82/src/dmd/backend/gflow.d#L1102 at `accumaecpx(n.EV.E2);`
Comment #7 by safety0ff.bugz — 2020-04-29T18:39:53Z
Created attachment 1781 preliminary patch Attached a preliminary patch. It doesn't help the other related bugzilla issues, but takes the test case from this issue from 1m5.368s -> 0m0.603s.
Comment #8 by dlang-bot — 2020-05-01T00:19:01Z
@WalterWaldron created dlang/dmd pull request #11085 "fix Issue 19550 - [REG 2.078] Massive compiler backend slowdown" fixing this issue: - fix Issue 19550 - [REG 2.078] Massive compiler backend slowdown Fixes typo which caused a redundant O(N^2) slowdown. https://github.com/dlang/dmd/pull/11085
Comment #9 by dlang-bot — 2020-05-01T19:48:44Z
dlang/dmd pull request #11085 "fix Issue 19550 - [REG 2.078] Massive compiler backend slowdown" was merged into master: - 8e4338627e5be46e79770289bb0948a9712a5330 by WalterWaldron: fix Issue 19550 - [REG 2.078] Massive compiler backend slowdown Fixes typo which caused a redundant O(N^2) slowdown. https://github.com/dlang/dmd/pull/11085