-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to chevrotain 7 #423
Comments
@bd82 do you think you could have a look ? I have to admit that I am a bit lost on the origin of the issue. Can we add a bounty on this @pascalgrimaud ? |
Starting with 200, which can be increased if it's a lot of work |
Chevrotain version 9.x is out |
There was a conditional inside the Try putting the |
Not sure a bounty is needed for this... |
Thanks a lot @bd82, it looks indeed that your suggestion works ! Even if it was so much work, you deserve the bounty for all the great work you did on this lib, so if you want to take it, it's yours !! |
I don't have a paypal account :) |
If it reduces the execution time, it is a good news, isn't it? Don't understand your smiley @clementdessoude |
Increase, sorry |
Oh in this case, it is not a good news indeed |
Is that for most test files or just for that single one? |
Comparing the logs between these two pipeline, it seems a common behaviour: For instance ConfigFileApplicationListener was parsed in 56ms in the first pipeline, and 140ms in the second one It is approximately the same on my computer |
There are not supposed to be any performance regressions, (definitively none so large). |
Possible things that can go wrong:
I'd think the first one is more likely |
Is the performance drop happening with the update to 7.x or to 9.x? |
It's in the update to 7.x. |
I will try to investigate it, but not sure when. |
I've finally have some time to start looking into it. I've had trouble with the local dev env because of windows + node-gyp + python. What I'm doing now is:
I can detect a performance regression switching from 6.5 to 7.0, but not x3 slower, rather 25-30% reduction. Perhaps it is some shenanigans inside of V8 engine's optimization... Perhaps I can try |
I think I was mistaken, the regression I noticed was likely between 6.5.0 and 7.12 (latest 7.x) But I can now repeatedly reproduce a performance regression between 7.1.0 -> 7.1.1 |
Okay this is the culprit: it was a refactor which made the exceptions use ES6 syntax and inheritance. What is happening is that due to the "naive" backtracking nature of the parser (no memorization)
A great many exceptions are thrown, when the parser tries and retries backtracking again and again. For samples under: `/packages/java-parser/samples/spring-framework/spring-expression/src/main/java/org/springframework/expression/spel/ Which are not that much code:
The So when the exception classes became more complex:
It negatively impacted the performance.
|
Possible SolutionsIn Chevrotain revert the exceptions implementation to the old styleProblems:
In java-parser implement a simple hackBasically use something like https://github.com/ds300/patch-package to apply a patch on the
This should be easy to perform and not too fragile as the exceptions file does not often change. In java-parser attempt to implement memoization on the backtracking logicThis is basically trying to improve the parsing backtracking algorithm.
But this will require more research to prove and time investment to implement. I will try to find time to open a separate issue with more details on this tomorrow |
I suspect that using the LL(*) plugin for chevrotain could get rid of much of the backtracking used in the Java-Parser. @msujew WDYT? Example of backtracking production:
Usage of the backtracking production:
Backtracking wrapper logic
|
Thanks @msujew Do you have any estimate or guess regarding what percentage of these lookaheads can be solved with LL* I am trying to understand if it may still be worth using the LL(*) plugin in this project. |
Why ?
We should try to have latest versions of our libs to include easily their improvements (bugs, enhancements, etc.)
What ?
I tried to upgrade, but ran into an error:
The text was updated successfully, but these errors were encountered: