Skip to content

Conversation

@parrt
Copy link
Member

@parrt parrt commented Nov 24, 2016

No description provided.

sharwell and others added 2 commits November 24, 2016 13:01
…ery large expression input phrases; builds off of @sharwell solution that explicitly checks for key return states in expr rules
@parrt parrt merged commit fdee94d into antlr:master Nov 25, 2016
@parrt parrt deleted the expr-performance-test branch November 25, 2016 04:30
@parrt
Copy link
Member Author

parrt commented Nov 25, 2016

Dear @antlr/antlr-targets folks, you should take a look at this small 60 line patch (method canDropLoopEntryEdgeInLeftRecursiveRule()) to ParserATNSimulator. It is a 10,000x speed boost. I added tests in PerformanceDescriptors that ignore all but Java target so you can unignore and see it take overnight to parse 10 lines. Then fix and it's fast :)

@parrt
Copy link
Member Author

parrt commented Nov 25, 2016

@hanjoes @pboyer looks like team antlr-targets invitation went to your spam buckets. can you check?

@hanjoes
Copy link
Member

hanjoes commented Nov 25, 2016

Yep, I've accepted the invitation.

@mike-lischke
Copy link
Member

mike-lischke commented Nov 25, 2016

Hmm, strange, your largest test case from this patch takes just 3ms in the C++ target using a much more complex expr rule set with several left recursions (see the MySQL grammar), without this patch. So, it might not have the same impact on already fast language targets. I'll work on the translation soon.

@sharwell
Copy link
Member

@mike-lischke this is an algorithm complexity change for the affected grammars. It only affects grammars and inputs with particular lookahead characteristics. For example, it affects the Java grammar yet no file in the entire JDK code base (12,000+ source files) hits the slow case. In other cases, the bad performance could be hit on a regular basis.

@mike-lischke
Copy link
Member

mike-lischke commented Nov 25, 2016

I understand, but Ter mentioned that the test grammars would take minutes for him, while in the C++ target they only take ms (without the patch). Which is what makes me wondering. Ah, I didn't use the same grammar (even though I believe I have an expr rule which has the same characteristics and is even more complex).

@parrt
Copy link
Member Author

parrt commented Nov 25, 2016

Also the new tests that I added are set to be ignored for all but the Java target... just in case it looked like they were executing okay.

@mike-lischke
Copy link
Member

mike-lischke commented Nov 27, 2016

Quite confusing what the actual patch is, when looking at this entry. I assume the thing that target author should care about is [fdee94d] (mentioned in the final merge)? But that's a bit more than 60 LOCs. @parrt btw, I can't find the C++ tests in runtime-tests/pom.xml file anymore. How are they now executed?

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Nov 28, 2016 via email

@parrt
Copy link
Member Author

parrt commented Nov 28, 2016

@ericvergnaud ok, lemme know if you need help

@parrt
Copy link
Member Author

parrt commented Nov 28, 2016

@mike-lischke You just have to implement function fdee94d#diff-49c5618cf842764cf250783fe7c0fe6cR1701 and inject a call to it elsewhere. the runtime tests work automatically.

@mike-lischke
Copy link
Member

@parrt yes, yes, I was just wondering why I didn't see a full patch link, only those from individual commits. But this is probably the result of the already closed pull request. A Github usability issue...

@pboyer
Copy link
Contributor

pboyer commented Nov 30, 2016

@parrt I don't see an invite for @antlr/antlr-targets in my email.

@parrt
Copy link
Member Author

parrt commented Nov 30, 2016

@pboyer i canceled and reinvited you. :) check spam

@parrt
Copy link
Member Author

parrt commented Nov 30, 2016

@mike-lischke yep, that's why i looked at "files changed" not "commits". much easier. :) Actually, i often pull into a branch and then run a diff on the two directories to see the complete set of changes.

@pboyer
Copy link
Contributor

pboyer commented Nov 30, 2016

Thanks @parrt! I'm in. "10,000x"? Sounds like only a constant factor to me! 😆 I'll give this a shot, ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants