tunnelvisionlabs / antlr4cs

The original, highly-optimized C# Target for ANTLR 4
Other
437 stars 104 forks source link

Slow performance #292

Open jvratanar opened 6 years ago

jvratanar commented 6 years ago

I am trying to parse some specific file format .px . I am a beginner with antlr4 and parser generators in general. I would really appreciate it if you would have a look why is performance so slow. I have the entire project at: https://github.com/jvratanar/Fpx I suspect that the grammar is poorly written, but i unfortunately was not able to find the grammar on the internet as this format is quite obscure. So i was forced to write it myself.

sharwell commented 6 years ago

The first step is to avoid using non-greedy operators like ??. They are extremely expensive currently.

jvratanar commented 6 years ago

I've removed ?? from the grammar. However the performance is still quite slow. Is it possible to target the whole parsing in the range of 1-2 seconds?

jvratanar commented 6 years ago

I switched to using UnbufferedCharStream and UnbufferedTokenStream and the parsinfg is still slow. I commented out the visitor section and the parsing is still very slow, so i suspect there is something wrong with the grammar. Do you have any tips on profiling this issue? When using VS Profiler the majority of time is spent in the Fpx.Generated.FpxParser::data -> Antlr4.Runtime.Parser::Match method