[antlr-interest] [C] reuse() - FIXED ... :-)

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Sat Nov 19 10:38:10 PST 2011


On 11/19/11 12:36 AM, "Ruslan Zasukhin" <ruslan_zasukhin at valentina-db.com>
wrote:

Hi Jim,
Hi All,

Now I am happy :))))))))

Everything below from my prev letter is right.
I have fix this couple places, and have discover yet couple required to be
improved for correct reuse():
   adaptor  -- factory of nillObjects
   factory of vectors

Now RAM do not grows absolutely and speed is
    v3 no reuse()       24 sec
    v3 with reused    19.4 sec
    v3 with reuse      19.7

And I believe I see yet few moments to improve for better speed.
I will try in nearest days ... Then inform here.

For example, it seems to me, we can perfectly reset also nodes from
treeparser. It have also pool. Everything is very similar ... So why to kill
pool and create it each time ...


Of course I have not get my dream x2 speedup using v3 :)
But at least not worse ...


> So I have debug debug and have found that
> 
> =================
> 1) Generated Parser contains ctx->adaptor, which contains one more
> tokenFactory. And for this factory NEVER is called reset().
> 
> I have add call reset() for now in the method of generated parser.
> This have made things better, but still I see at least two players...
> 
> So next player is:
> 
> =================
> 2) This adaptor also has more deeply hidden factory of trees.
> And it is called a lots for nilNode().
> 
> And this factory 
>     typedef    struct ANTLR3_ARBORETUM_struct
> 
> Although is very similar to
>     typedef    struct ANTLR3_TOKEN_FACTORY_struct
> 
> In work with pools, it do NOT have reset() function.
> 
> So I think I will try add reset() method to this struct,
> And call it from generated parser reset() method as following
> 
> 
> static void
> SqlParser_v3ParserReset (pSqlParser_v3Parser ctx)
> {
>     RECOGNIZER->reset(RECOGNIZER);
>     
>     // RZ added this to see if this fixes grow of RAM.
>     
>     ADAPTOR->tokenFactory->reset( ADAPTOR->tokenFactory );
>     
>     ((pANTLR3_COMMON_TREE_ADAPTOR)(ADAPTOR->super))->arboretum->reset(
>         (ADAPTOR->super))->arboretum);
> }
> 
> 

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the antlr-interest mailing list