www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Pegged and DMD Compilation Memory

reply d coder <dlang.coder gmail.com> writes:
--f46d04016d8f681be304c0b5a5dd
Content-Type: text/plain; charset=ISO-8859-1

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"
));

--f46d04016d8f681be304c0b5a5dd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Greetings<div><br></div><div>I am trying to use Pegged for compile time par=
sing. 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 co=
mes bundled with Pegged.</div>


<div><br></div><div>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 D=
MD 2.059. I am using the latest Pegged code from github.</div>

<div><br></div><div>Regards</div><div>- Puneet</div><div><br></div><div><di=
v>mixin(grammar(</div><div>=A0 =A0&quot;CstGrammar:</div><div>=A0 =A0 CstSe=
t =A0 =A0 &lt; =A0Cst+</div><div>=A0 =A0 Cst =A0 =A0 =A0 =A0&lt; =A0Bool &#=
39;;&#39;</div><div>=A0 =A0 Bool =A0 =A0 =A0 &lt; =A0Comparison BoolExpr*</=
div>

<div>=A0 =A0 BoolExpr =A0 &lt; =A0^(&#39;&amp;&amp;&#39;/&#39;||&#39;) Comp=
arison</div><div>=A0 =A0 Comparison &lt; =A0Expr CompExpr?</div><div>=A0 =
=A0 CompExpr =A0 &lt; =A0^(&#39;&lt;=3D&#39;/&#39;&gt;=3D&#39;/&#39;!=3D&#3=
9;/&#39;&lt;&#39;/&#39;&gt;&#39;/&#39;=3D=3D&#39;) Expr</div>

<div>=A0 =A0 Expr =A0 =A0 =A0 &lt; =A0Factor AddExpr*</div><div>=A0 =A0 Add=
Expr =A0 =A0&lt; =A0^(&#39;+&#39;/&#39;-&#39;) Factor</div><div>=A0 =A0 Fac=
tor =A0 =A0 &lt; =A0Primary MulExpr*</div><div>=A0 =A0 MulExpr =A0 =A0&lt; =
=A0^(&#39;*&#39;/&#39;/&#39;) Primary</div>

<div>=A0 =A0 Primary =A0 =A0&lt; =A0Parens / Number / Variable / ^&#39;-&#3=
9; Primary</div><div>=A0 =A0 Parens =A0 =A0 &lt; =A0&#39;(&#39; Bool &#39;)=
&#39;</div><div>=A0 =A0 Number =A0 =A0 &lt;~ [0-9]+</div><div>=A0 =A0 Varia=
ble =A0 &lt;- Identifier&quot;</div>

<div>));</div></div><div><br></div>

--f46d04016d8f681be304c0b5a5dd--
May 23 2012
next sibling parent 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
prev sibling next sibling parent d coder <dlang.coder gmail.com> writes:
--f46d04083de74bca5604c0b62bb4
Content-Type: text/plain; charset=ISO-8859-1

 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? --f46d04083de74bca5604c0b62bb4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote"><br><blockquote class=3D"gmail_quote" style=3D"m= argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dmd simply ne= ver frees any memory it allocates.</blockquote></div><br><div>Since GDC use= s DMD front-end, I do not think I can get any relief by using that too. Rig= ht?</div> --f46d04083de74bca5604c0b62bb4--
May 23 2012
prev sibling next sibling parent 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
prev sibling next sibling parent 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
prev sibling next sibling parent "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
prev sibling next sibling parent 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
prev sibling 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