D's memory-hungry templates

maik klein via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 9 12:56:59 PDT 2016


On Thursday, 9 June 2016 at 14:46:12 UTC, tsbockman wrote:
> While working on a small PR 
> (https://github.com/dlang/phobos/pull/4420), I noticed that D's 
> template computation system has horrific memory consumption (as 
> well as being very slow).
>
> [...]

I run into the same issues with 
https://maikklein.github.io/2016/03/01/metaprogramming-typeobject/

I think doing metaprogramming that way is really neat but the 
memory consumption if I remember correctly was around 50 times 
worse than doing it without "type objects".

Also C++ beat D in every compile time meta programming benchmark 
that I have tested.

The only time when D was roughly as fast as C++ was with string 
mixins but they are even more memory hungry.

Stuff like filtering odd integers from an AliasSeq of 100k 
elements etc. I mostly recreated those benchmarks in D 
https://github.com/boostorg/hana/tree/master/benchmark

The only time when D compiled roughly as fast as C++ was with 
string mixins and they are even more memory hungry.


More information about the Digitalmars-d mailing list