[antlr-interest] Re: newbie question

Don Caton dcaton at shorelinesoftware.com
Tue Oct 26 10:25:21 PDT 2004



> At any rate.. now.. I need to figure out how to improve it's 
> speed.  I assume there is a penalty (that I will have to live 
> with) for "greedy=true".  However, are there some things I 
> could do to make this speedier?  On my test platform, I'm 
> only parsing about 15k lines/second.

First, forget about the Antlr runtime library, just link the cpp files
directly into your project.  Make copies and put them in your project
directory, or a subdirectory.  Next, take all of the stuff in CommmonAST.cpp
and put it in CommonAST.hpp.  This allows the compiler to inline most, if
not all of it.  Some of the other Antlr classes may benefit from this as
well, but CommonAST seems to be the most used class in the parsers.

Now, if you are using MSVC, go into the properties dialog for the project
and in your release build settings, enable the following options:

  /O2  maximize speed
  /Og  global optimizations
  /Ob2 inline any suitable functions
  /Oi  enable intrinsic functions
  /Ot  favor fast code

And under linker options:

  /OPT:REF eliminitate unreferenced data
  /OPT:ICF remove redundant comdats

Build a release version and you will see a dramatic speed increase.  My
ANTLR generated parsers run 10-15 times faster when built with these
options.  The downside is that it takes MSVC 20 minutes to build my
executable, so it's only suitable for test or release builds.  You wouldn't
want to build a development version using these options anyhow or it would
be difficult to debug.

If you're using some other flavor of C++, see if there are similar
optimizations you can perform.

Regards,
 
Don Caton
Shoreline Software, Inc.
 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list