Bug 11009 – Regression (2.064 git-head): DMD consumes huge memory when it compiles enum containing many items
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-11T02:14:00Z
Last change time
2013-09-12T06:56:20Z
Assigned to
nobody
Creator
kekeniro2
Comments
Comment #0 by kekeniro2 — 2013-09-11T02:14:31Z
DMD consumes over 1GB memory and runs slow when compiling the code below.
And it won't compile my project by out-of-memory.
I have just got it from git head.
This should be a recent regression.
CODE:
import std.conv;
void main() {
Items t;
t.to!string();
}
enum Items {
// 200 items contained
ID001,ID002,ID003,ID004,ID005,ID006,ID007,ID008,ID009,ID010,
ID011,ID012,ID013,ID014,ID015,ID016,ID017,ID018,ID019,ID020,
ID021,ID022,ID023,ID024,ID025,ID026,ID027,ID028,ID029,ID030,
ID031,ID032,ID033,ID034,ID035,ID036,ID037,ID038,ID039,ID040,
ID041,ID042,ID043,ID044,ID045,ID046,ID047,ID048,ID049,ID050,
ID051,ID052,ID053,ID054,ID055,ID056,ID057,ID058,ID059,ID060,
ID061,ID062,ID063,ID064,ID065,ID066,ID067,ID068,ID069,ID070,
ID071,ID072,ID073,ID074,ID075,ID076,ID077,ID078,ID079,ID080,
ID081,ID082,ID083,ID084,ID085,ID086,ID087,ID088,ID089,ID090,
ID091,ID092,ID093,ID094,ID095,ID096,ID097,ID098,ID099,ID100,
ID101,ID102,ID103,ID104,ID105,ID106,ID107,ID108,ID109,ID110,
ID111,ID112,ID113,ID114,ID115,ID116,ID117,ID118,ID119,ID120,
ID121,ID122,ID123,ID124,ID125,ID126,ID127,ID128,ID129,ID130,
ID131,ID132,ID133,ID134,ID135,ID136,ID137,ID138,ID139,ID140,
ID141,ID142,ID143,ID144,ID145,ID146,ID147,ID148,ID149,ID150,
ID151,ID152,ID153,ID154,ID155,ID156,ID157,ID158,ID159,ID160,
ID161,ID162,ID163,ID164,ID165,ID166,ID167,ID168,ID169,ID170,
ID171,ID172,ID173,ID174,ID175,ID176,ID177,ID178,ID179,ID180,
ID181,ID182,ID183,ID184,ID185,ID186,ID187,ID188,ID189,ID190,
ID191,ID192,ID193,ID194,ID195,ID196,ID197,ID198,ID199,ID200,
}
(In reply to comment #2)
> (In reply to comment #1)
> > This smells like
> > https://github.com/D-Programming-Language/phobos/pull/1540
> >
> > Could you try it without that change?
>
> I tried it, and you are right.
Cool.
I think I know what might be the culprit. May I request you try it with HEAD again, but this time, replace:
line 829-832:
// generate a switch statement with string literals instead of allocating memory
// @@@BUG@@@ 10950 workaround: [CTFE] enum "char[]" not correctly duplicated when used.
enum rep(S val) = mixin(format(`"%s"%s`,
toStr!string(val), charLiteralSuffix!(ElementEncodingType!T)));
With:
template rep(S val)
{
static immutable(T) rep = toStr!(immutable(T))(val);
}
I have a hunch that should greatly improve the situation.
Comment #4 by kekeniro2 — 2013-09-11T03:53:37Z
(In reply to comment #3)
> I think I know what might be the culprit. May I request you try it with HEAD
> again, but this time, replace:
> line 829-832:
> // generate a switch statement with string literals instead of allocating
> memory
> // @@@BUG@@@ 10950 workaround: [CTFE] enum "char[]" not correctly duplicated
> when used.
> enum rep(S val) = mixin(format(`"%s"%s`,
> toStr!string(val), charLiteralSuffix!(ElementEncodingType!T)));
>
> With:
> template rep(S val)
> {
> static immutable(T) rep = toStr!(immutable(T))(val);
> }
I tried it, but you are wrong.
Comment #5 by monarchdodra — 2013-09-11T04:57:36Z
(In reply to comment #4)
>
> I tried it, but you are wrong.
Ah. OK. Thanks.
I think I know what else is wrong, but I'll investigate myself.
Comment #6 by monarchdodra — 2013-09-11T05:28:48Z
(In reply to comment #5)
> (In reply to comment #4)
> >
> > I tried it, but you are wrong.
>
> Ah. OK. Thanks.
>
> I think I know what else is wrong, but I'll investigate myself.
OK. I found out exactly what was wrong. I'll fix it ASAP.
Thanks for reporting, and sorry for the inconvenience.
Comment #7 by github-bugzilla — 2013-09-12T06:55:37Z