www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Pegged and DMD Compilation Memory

reply d coder <dlang.coder gmail.com> writes:
Greetings

I am trying to use Pegged for compile time parsing. The only issue I am
facing is with the compile time memory. I have a rather simple grammar,
mostly derived from the arithmetic.d example that comes bundled with Pegged.

I am wondering if the memory could be optimized by fine-tuning the code in
the grammar that I have written. I am pasting the code down here for
suggestions. On my 64-bit linux machine my small application is taking as
much as 2.2GB of RAM at the time of compiling the code using DMD 2.059. I
am using the latest Pegged code from github.

Regards
- Puneet

mixin(grammar(
   "CstGrammar:
    CstSet     <  Cst+
    Cst        <  Bool ';'
    Bool       <  Comparison BoolExpr*
    BoolExpr   <  ^('&&'/'||') Comparison
    Comparison <  Expr CompExpr?
    CompExpr   <  ^('<='/'>='/'!='/'<'/'>'/'==') Expr
    Expr       <  Factor AddExpr*
    AddExpr    <  ^('+'/'-') Factor
    Factor     <  Primary MulExpr*
    MulExpr    <  ^('*'/'/') Primary
    Primary    <  Parens / Number / Variable / ^'-' Primary
    Parens     <  '(' Bool ')'
    Number     <~ [0-9]+
    Variable   <- Identifier"
));
May 23 2012
parent reply Trass3r <un known.com> writes:
 I am trying to use Pegged for compile time parsing. The only issue I am
 facing is with the compile time memory
dmd simply never frees any memory it allocates.
May 23 2012
next sibling parent d coder <dlang.coder gmail.com> writes:
 dmd simply never frees any memory it allocates.
Since GDC uses DMD front-end, I do not think I can get any relief by using that too. Right?
May 23 2012
prev sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 23 May 2012 16:55, d coder <dlang.coder gmail.com> wrote:
 dmd simply never frees any memory it allocates.
Since GDC uses DMD front-end, I do not think I can get any relief by using that too. Right?
No relief am afraid. I do know of someone in the past using the Boehm GC with GDC, which vastly improved memory consumption. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 23 2012
parent reply Trass3r <un known.com> writes:
 No relief am afraid.  I do know of someone in the past using the Boehm
 GC with GDC, which vastly improved memory consumption.
Didn't they try to enable the GC in dmd recently but it was a little disaster?
May 23 2012
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, May 23, 2012 18:21:42 Trass3r wrote:
 No relief am afraid. I do know of someone in the past using the Boehm
 GC with GDC, which vastly improved memory consumption.
Didn't they try to enable the GC in dmd recently but it was a little disaster?
Yeah. It hurt compile times considerably. I'm not sure what the current plan is, other than leaving it like it is for now. The current situation can result in pretty atrocious memory usage by dmd, but there are more critical things for Walter et al. to be working on, hence why it hasn't really been addressed yet. - Jonathan M Davis
May 23 2012
parent reply Trass3r <un known.com> writes:
 Didn't they try to enable the GC in dmd recently but it was a little
 disaster?
Yeah. It hurt compile times considerably. I'm not sure what the current plan is, other than leaving it like it is for now.
What about good old properly managing the memory manually? At least for new code and maybe improving old code gradually.
May 23 2012
parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, May 23, 2012 21:33:14 Trass3r wrote:
 Didn't they try to enable the GC in dmd recently but it was a little
 disaster?
Yeah. It hurt compile times considerably. I'm not sure what the current plan is, other than leaving it like it is for now.
What about good old properly managing the memory manually? At least for new code and maybe improving old code gradually.
I have no idea how any of that stuff is set up in the compiler, so I don't know what would or wouldn't be reasonable for it to do. - Jonathan M Davis
May 23 2012