|
I have just checked in some changes to the C
target code generation templates and the C runtime itself in order to
greatly improve AST construction and rewrites. Depending on quite what
you do with your grammar, this will have a huge effect on performance. If you want the full nitty-gritty on the changes, look at the code changes for perforce change list #s 5558 and 5559. The changelist comment for 5559 is below. I will continue to look for optimizations and ways to reduce the system time, but getting reasonably close to the hand crafted gcc seems good enough for the moment, while I fix the remaining few runtime bugs ready for 3.1.2. I would appreciate it if those of you that use the C target would download the latest Antlr Tool (codegen templates have changed so you need the latest build) and runtime distribution and give this a try. Testing your own code and calling it good is never a good idea ;-) PLease make sure that the build you download includes these changes, which it should be build #20 for the C runtime and build #49 for the ANTLR Tool. Jim - - - - - C target Tree rewrite optimization There is only one optimization in this change, but it is a huge one. The code generation templates were set up so that at the start of a rule, any rewrite streams mentioned in the rule were pre-created. However, this is a massive overhead for rules where only one or two of the streams are actually used, as we create them then free them without ever using them. This was copied from the Java templates basically. This caused literally millions of extra calls and vector allocations in the case of the GNU C parser given to me for testing with a 20,000 line program. After this change, the following comparison is avaiable against the gcc compiler: Before (different machines here so use the relative difference for comparison): gcc: real 0m0.425s user 0m0.384s sys 0m0.036s ANTLR C real 0m1.958s user 0m1.284s sys 0m0.656s After the previous optimizations for vector pooling via a factory, plus this huge win in removing redundant code, we have the following (different machine to the one above): gcc: 0.21user 0.01system 0:00.23elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+328outputs (0major+9922minor)pagefaults 0swaps ANTLR C: 0.37user 0.26system 0:00.64elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+130944minor)pagefaults 0swaps The extra system time coming from the fact that although the tree rewriting is now optimal in terms of not allocating things it does not need, there is still a lot more overhead in a parser that is generated for generic use, including much more use of structures for tokens and extra copying and so on. I will continue to work on improviing things where I can, but the next big improvement will come from Ter's optimization of the actual code structures we generate including not doing things with rewrite streams that we do not need to do at all. The second machine I used is about twice as fast CPU wise as the system that was used originally by the user that asked about this performance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~--- |
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
