Bug 22330 – Huge memory consumption for optimized DMD builds with LDC host compiler
Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-09-22T16:16:52Z
Last change time
2021-09-22T16:41:08Z
Assigned to
No Owner
Creator
kinke
Comments
Comment #0 by kinke — 2021-09-22T16:16:52Z
For a pretty large private project, I've noticed that optimized DMD built with LDC host compilers can require almost twice as much memory (peak working set shown by /usr/bin/time -v) than unoptimized DMD builds. This is with DMD v2.097.2 on Linux x64; using itself as host compiler doesn't show this behavior. I've tested LDC v1.27.0, v1.25.1 and v1.21.0 as host compilers (incl. different LLVM versions), the behavior is consistent.
With -o-, the memory consumption is ~17 GB with all DMD builds.
With -c, it's still ~17 GB for all builds with DMD host compilers and the unoptimized LDC host compiler build. With the ENABLE_RELEASE=1 LDC host compiler build, it's almost 19 GB.
With -lib, it's still around 17 GB for all builds *except* the LDC-optimized build, where it explodes to almost 31 GB. With official DMD v2.097.2, it's around 29 GB (not sure how that's built exactly).
I hope this strangeness can be reproduced with arbitrary non-tiny projects. The fact that -o- is stable appears to confine it to the DMD glue/codegen layer. I cannot rule out that LDC is to blame, but I guess it's more likely that something's off in the DMD backend code.
Comment #1 by kinke — 2021-09-22T16:41:08Z
Oh no, I've missed that somehow all builds except the LDC-optimized one segfault. :D - Sorry for the noise.