cjheath / treetop

A Ruby-based parsing DSL based on parsing expression grammars.

Home Page:https://cjheath.github.io/treetop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing performance deterioration since 1.5

snecklifter opened this issue · comments

Hello,

As per asciidoctor/asciidoctor-pdf#1339

I am wondering if there is a reason for the performance degradation seen in asciidoctor-pdf and if this is something that can be easily fixed?

There is very little runtime difference between these Treetop versions. The only thing I can point to that might make a tiny difference is that SyntaxNodes now store a reference to their parent node, at the point where that parent node gets instantiated. That will increase storage a small amount and take a tiny bit longer. It's hard to see that this could be responsible for your issues, but it's not likely to get reversed. It's just too hard to debug a Treetop grammar and to issue sensible error messages when it's not possible to see a Node's context.

We've decided to accept this change. The performance degradation is measurable, but compared to other operations performed in the application, insignificant. And your reasoning for why it must be this way is understandable.

There's one other difference I notices when I generate the grammar with 1.6 instead of 1.5. Sometimes, the node extends the same type twice:

r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
r0.extend(Complex0)
r0.extend(Complex0)

I would think the generator would check for this. Let me know if you think that is a valid concern and thus need me to file a separate issue.