Templates are slow.
Johan Engelen via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 8 13:28:44 PDT 2016
On Thursday, 8 September 2016 at 19:17:42 UTC, Lewis wrote:
>
> Am I crazy in wondering about caching template instantiations?
> I understand that an incremental build would kind of accomplish
> this goal, but that comes with its own set of problems.
Not as good as what you propose, but: LDC 1.1.0 can do _codegen_
caching which I guess is some intermediate form of incremental
building.
My testcase is a unittest piece from Weka.io that instantiates,
oh, I don't remember exactly, 100.000+ templates. It takes about
65 seconds to compile. With codegen caching, the re(!)compile
time on cache-hit is reduced to 39s. Note that the front-end
still instantiates all those templates, but LDC's codegen at -O0
is not as fast as DMD's (calculating the hash also takes time and
could be optimized further).
In summary, for LDC -O3 builds, you can expect a large speed
boost by just adding `-ir2obj-cache=<cache dir>` to the
commandline (LDC >= 1.1.0-alpha1).
-Johan
More information about the Digitalmars-d
mailing list