DMD performance issues with deeply-recursive templates
Peter Alexander
peter.alexander.au at gmail.com
Thu Jul 25 01:17:27 PDT 2013
On Thursday, 25 July 2013 at 04:33:59 UTC, H. S. Teoh wrote:
> From what I can tell from a cursory glance, it's caused by the
> implementation of cartesianProduct using too many template
> expansions
> (esp. in the variadic version of cartesianProduct), causing DMD
> to run
> very slowly and eventually exhaust all available memory and
> crash.
Actually, it's probably caused by the exponential size of
template symbol names thanks to mangling of eponymous templates:
int[] a, b, c, d;
writeln(typeof(cartesianProduct(a, b)).mangleof.length);
writeln(typeof(cartesianProduct(a, b, c)).mangleof.length);
writeln(typeof(cartesianProduct(a, b, c, d)).mangleof.length);
534
4025
25003
I can't even get it to compile with 5 params, but it's increasing
by a factor of 6 or 7 each time, so 5 will be hundred of KB, 6
will be MBs and 7 will be 10s of MB.
This needs to be fixed. Simply compressing the names will not
help, we need a better mangling scheme.
More information about the Digitalmars-d
mailing list