Bug 24052 – DMD frontend inliner causes major slowdown

Status
NEW
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-07-20T15:59:18Z
Last change time
2024-12-13T19:30:15Z
Assigned to
No Owner
Creator
Grim Maple
Moved to GitHub: dmd#20315 →

Comments

Comment #0 by grimmaple95 — 2023-07-20T15:59:18Z
I recently noticed that dmd takes an atrociously long time to pass Build & Test phase of dlangui github actions. Example: https://github.com/buggins/dlangui/actions/runs/5181817896/job/14021883521 LDC takes 1m 30s on Linux and 3m 54s on Windows DMD takes 59m (!!!) 18s on Linux and 1 HOUR 30 minutes on Windows
Comment #1 by maxhaton — 2023-07-20T16:14:02Z
Only in CI?
Comment #2 by dkorpel — 2023-07-20T16:27:29Z
dub test is pretty quick, it takes long building example1 in release mode, which makes me suspect dmd's backend's optimizer. Possibly issue 23857
Comment #3 by grimmaple95 — 2023-07-20T16:30:17Z
(In reply to Dennis from comment #2) > dub test is pretty quick, it takes long building example1 in release mode, > which makes me suspect dmd's backend's optimizer. Possibly issue 23857 Tested on my local machine, it is `dub build -b=release` that causes a slow compile time. Not necessarily on example1, dlangui itslef takes ages to compile too.
Comment #4 by dkorpel — 2023-07-21T09:44:47Z
(In reply to Grim Maple from comment #3) > Tested on my local machine, it is `dub build -b=release` that causes a slow > compile time. Not necessarily on example1, dlangui itslef takes ages to > compile too. You're right. I found that the culprit is the recursive function src/dlangui/graphics/resources.d : embedResources being inlined. Adding pragma(inline, false) fixes it, so this is indeed a duplicate of issue 23857.
Comment #5 by dkorpel — 2023-07-21T10:27:06Z
Actually, this looks like an issue with the frontend inliner, so no duplicate. Reduction so far: ```D struct EmbeddedResource { string a; const ubyte[] b; string c; } EmbeddedResource[] embedResource(string resourceName)() { immutable ubyte[] data = [0, 1, 2, 3, 4]; immutable string resdir = "res"; static if (data.length > 0) return [EmbeddedResource(resourceName, data, resdir)]; else return []; } EmbeddedResource[] embedResources(string[] names)() { static if (names.length == 0) return []; static if (names.length == 1) return embedResource!(names[0])(); else return embedResources!(names[0 .. $/2])() ~ embedResources!(names[$/2 .. $])(); } enum string[] stringArray = () { string[350] result; static foreach (i; 0 .. result.length) result[i] = "test" ~ i.stringof; return result; } (); void main() { embedResources!stringArray(); } ```
Comment #6 by robert.schadek — 2024-12-13T19:30:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20315 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB