The ANTLR4 benchmarks repository is ready #1
Replies: 10 comments 30 replies
-
Hey @mike-lischke, no problem. Great initiative 👌 My languages of choice are Java and C#. I'll have a look at your current benchmarks this weekend and will add them for Java and C# (if someone doesn't beat me to the punch). |
Beta Was this translation helpful? Give feedback.
-
I will need to think about this, but performance is an interest of mine. I just added a PR for the grammars-v4 repo for a workflow to test performance changes in a PR for a grammar. (antlr/grammars-v4#4023) One problem of a FOSS repo of Antlr4 grammars is making sure any change to a grammar doesn't screw it up any more than it is. The new workflow tests the "before" and "after" versions of a grammar change, running the examples for the grammar up to 40 times ("grouped", approximately equal to a "warmed up" parser) to gather information about how the grammar performs. The test uses Octave to perform a Welch 2-sample test to see if there is a "statistical significant" difference, and a drop in the ratio of the mean performance by a few percent for a "practical significant" difference. Of course, if the test input files for a grammar don't exercise all parts of the grammar, then it's likely the workflow won't find anything. And, for many grammars, the test input don't test even 25% of the entire grammar. (antlr/grammars-v4#3511) |
Beta Was this translation helpful? Give feedback.
-
Interesting. Am I correct in observing that testing grammar performance is different from testing runtime performance ? And that the latter may trigger different results from one grammar to another ?Would it make sense to provide simple means to check for grammar coverage and for runtime coverage ?Envoyé de mon iPhoneLe 28 mars 2024 à 20:44, Ken Domino ***@***.***> a écrit :
I will need to think about this, but performance is an interest of mine.
I just added a PR for the grammars-v4 repo for a workflow to test performance changes in a PR for a grammar. (antlr/grammars-v4#4023) One problem of a FOSS repo of Antlr4 grammars is making sure any change to a grammar doesn't screw it up any more than it is. The new workflow tests the "before" and "after" versions of a grammar change, running the examples for the grammar up to 40 times ("grouped", approximately equal to a "warmed up" parser) to gather information about how the grammar performs. The test uses Octave to perform a Welch 2-sample test to see if there is a "statistical significant" difference, and a drop in the ratio of the mean performance by a few percent for a "practical significant" difference. Of course, if the test input files for a grammar don't exercise all parts of the grammar, then it's likely the workflow won't find anything. And, for many grammars, the test input don't test even 25% of the entire grammar. (antlr/grammars-v4#3511)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Correct. There is a difference in grammar performance vs runtime performance. Testing the changes in a grammar of a PR should help to clarify whether the PR introduces "badness" (e.g., ambiguity). I'm hoping the workflow will help, but I don't know until I see it in action for the next month or so.
Correct. I have seen some really weird caching issues that exist in some runtimes but not others.
I have a tool that displays the coverage of the parse of a collection of input. It outputs an html file with the grammar colorized according to rule usage in all the parses by checking the types of nodes in all of the parse trees outputted. However, it doesn't colorize the grammar that |
Beta Was this translation helpful? Give feedback.
-
Interesting! I'll try it when I complete my own ANTLR runtime (more or less). |
Beta Was this translation helpful? Give feedback.
-
Question about the MySQL grammar. You have the grammar in this repo, in multiple places. It is not in target-agnostic format, nor in StringTemplate format, which is why there are many copies here for Cpp, here for Antlr TypeScript 4.13.1, here for Antlr4ng, here for Antlr4ts. Presumable, you'd have to make ports for any other targets like Java, CSharp, Go, Python3, JavaScript, and Dart. (Note, I am ignoring PHP because it is so full of serious hash code errors to be useless, and I cannot convince the author that the code is all wrong.) Why is the grammar not in target-agnostic or a StringTemplate format? Can I please add this grammar to grammars-v4/sql/mysql/Oracle/mysql-version-such-and-such and make it target-agnostic format? I have a huge ecosystem to analyze this grammar, but I cannot do that if not in one or the other format. (It has to be in target-agnostic format for grammars-g4 because everyone expects the .g4 to be used as is, not preprocessed via StringTemplates as Trash can handle.) |
Beta Was this translation helpful? Give feedback.
-
Sorry, you are right. I just noticed that you already have the code in base classes.
Yes, that is true, but that's exactly what "transformGrammar is all about. Yes, it is a totally disgusting hack, but it allows for the grammar to be shared for all targets. Rather than have all these different syntax, the grammar always uses "this." in all actions, and transformGrammmar.py replaces the pattern with the appropriate syntax. To be really "target agnostic", you shouldn't even use operators like For Cpp, the semantic action https://github.com/mike-lischke/antlr4-runtime-benchmarks/blob/a971852628d9ecca0ce79c7972e3c026017bdadc/src/mysql/targets/antlr4-cpp/MySQLLexer.g4#L474C90-L474C111 does not have a "this->", but is it required because the field is already declared in the base class. In most grammars, the "transformGrammar.py" hack is required to mutate "this." to "this->". For JavaScript and TypeScript, "this." must be used https://github.com/mike-lischke/antlr4-runtime-benchmarks/blob/a971852628d9ecca0ce79c7972e3c026017bdadc/src/mysql/targets/antlr4/MySQLLexer.g4#L486C90-L486C116 . But, since we already require "this." for all field and method references for "target agnostic format", it's fine as is. For Go, lexer predicates must be reference with "l." which parser predicates are "p.". Etc., etc., etc. A much better solution would be to provide a StringTemplate expansion for the target. A PR was added for this here: antlr/antlr4#4345 , but personally, I'd make the entire file a string template, and prefix or suffix the file with .st, and just apply ST through the whole file. Trash already does this. (You have to have a tool like trgen because Java requires base class code to be in a specific directory structure if you use a |
Beta Was this translation helpful? Give feedback.
-
I have now stripped out any code which is not needed for the benchmarks. Statement splitting for SQL benchmarks is done by splitting the file content at a known delimiter (here |
Beta Was this translation helpful? Give feedback.
-
@bkiers, @kaby76 Have you had a chance to work on another target language for the MySQL benchmarks? It doesn't need to be that grammar, however. Pick any other you think it's worth to be included. I can then add a TypeScript and C++ variant. @KvanTTT Have you thought about adding some of your other benchmarks to this repo? Would be fun to see how Python and PHP do in these benchmarks. |
Beta Was this translation helpful? Give feedback.
-
Somewhat related, here is my original ANTLRV3 grammar for TSQL 2008R2 converted to v4. Feel free to test it, or put it into the benchmarks. It was max LL(3) in v3, but I have not analyzed t exactly in v4. But it is very efficient and suffers from none of the issue in the other grammars published in contributions (MIke's grammar excepted).
https://github.com/jimidle/tsqlparser
jimidle/tsqlparser: An implementation of an ANTLR4 TSQL grammar at the 2008R2 spec
github.com
… On May 4, 2024, at 13:47, Mike Lischke ***@***.***> wrote:
Closed #1 <#1> as resolved.
—
Reply to this email directly, view it on GitHub <#1>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJ7TMGBXLMKWGVEPNUSSSTZAU3NBAVCNFSM6AAAAABFNCPNAOVHI2DSMVQWIX3LMV45UABFIRUXGY3VONZWS33OIV3GK3TUHI5E433UNFTGSY3BORUW63R3GEZDKOBWGI2Q>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
I finally managed to realize an idea I had for a long time: creating a repository for comparing performance numbers of different ANTLR4 runtimes, for different grammars (only a selection of course). Currently only the MySQL grammar is used, but I hope to add more.
@kaby76, @KvanTTT, @parrt, @jimidle, @ericvergnaud, @ftomassetti, @lppedd, @bkiers, I would like to invite you to work with me on this repository. What is it you could do?
What's in for you guys?
Hopefully I can convince some of you to be part of this effort!
Thanks, Mike
Beta Was this translation helpful? Give feedback.
All reactions