Bug 14805 – [REG2.064] Unreasonably slow "new Struct[large]"
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-17T17:42:00Z
Last change time
2015-07-24T03:20:23Z
Keywords
performance, pull
Assigned to
nobody
Creator
wyrlon
Comments
Comment #0 by wyrlon — 2015-07-17T17:42:11Z
struct Struct
{
ushort one;
}
auto dummy = new Struct[513*513];
The above program takes ~50s to compile on a modern computer.
No difference between:
v2.067.1
v2.068.0-b1
Comment #1 by gassa — 2015-07-17T17:57:21Z
Same here.
Maybe it generates an instance of the array at compile time?
Compile-time function execution is known to be slow.
Interestingly,
void main () {auto dummy = new Struct[513 * 513];}
and even
void main () {enum dummy = new Struct[513 * 513];}
compile just fine.
(In reply to Ivan Kazmenko from comment #1)
> Maybe it generates an instance of the array at compile time?
it is, indeed. `auto dummy = new Struct[513*513];` can be evaluated in compile time, and compiler does exactly that. this will also produce a huge .o file with mostly zeroes (.init) inside.