whatever I do, things get slower and bigger

Moritz Warning moritzwarning at _nospam_web.de
Thu Mar 13 17:07:25 PDT 2008

On Fri, 14 Mar 2008 08:42:27 +0900, Bill Baxter wrote:

> BCS wrote:
>> I'm working on my parser generator and trying to shoe horn it into a
>> smaller memory foot print. One approach I'm trying, is to replace
>> recursive templates with CTFE function and string mixins. This is in an
>> effort to reduce the number of types that get declared (mostly I'm
>> using struct templates). The problem is that the CTFE functions seem to
>> actually use MORE ram than the templates do. I've tried a number of
>> things like converting to an O(n log n) concatenation system rather
>> than a O(n^2) and other such tricks but everything seems to be going
>> backwards. Any advice? (D v1 BTW) I can post code if anyone cares (it's
>> kind of large: 1.2KLOC, takes a while to compile: ~6min, and use a lot
>> of RAM: ~2GB).
>> (after a bit more fiddling)
>> I've got it down to 1GB of ram (Yeah!). My conclusions: don't build
>> strings with CTFE unless it's a lot harder to do it with templates. It
>> seems that CTFE is a bigger memory hog than templates even with temples
>> memoizing everything into the symbol tables.
> Yes I believe Don has previously reported that CTFE manipulations on
> strings basically *never* free the intermediate strings.  Basically the
> CTFE engine needs a garbage collector (or equiv).
> --bb

Looks like D needs a script engine for CTFE
that makes use of a GC. Would be a good feature imho.

Reminds me of Virgil when I heard about in a post some time ago.
Virgil uses a compile time GC that includes reachable memory
into the binary for some kind of memory pre-allocation.


More information about the Digitalmars-d-learn mailing list