-
Notifications
You must be signed in to change notification settings - Fork 79
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
Safe memoization during parse graph flattening #2136
base: feat/error-recovery
Are you sure you want to change the base?
Conversation
We can cross the 2^31 boundary because of sharing.
Config object replaces ever growing list of parameters
Hi @arnoldlankamp, your comments on #2100 really helped out. Do you have some time to take a look at this? Thanks. ps. @PieterOlivier I think this means you should close #2100 ? |
Definitely, I have done so now. |
I'll have a look at it as soon as I'm able. |
This PR improves the memoization strategy during parse graph flattening. The original proved both incorrect and too slow in the context of the highly ambiguous and cyclic parse forests produced by error recovery.
Special thanks to @arnoldlankamp who came up with the following three heuristics specifying when nodes can be safely cached for memoization:
This PR implements a new caching strategy based on these heuristics.
We have gone through great lengths to test the correctness and performance of the code in this PR.
We already had a test suite that tested error recovery on all characters in all Rascal source files in the rascal repo using
two tests: delete the single character and delete all characters until the end-of-line.
We modified these tests to:
In all cases where the parse without memoization succeeded, the parse with memoization resulted in
exactly the same tree as the tree build without memoization. This in contrast with the old memoization approach where in the same test the result with memoization was often different from the result without memoization.
We have also setup a performance benchmark to compare the speed of "normal" parsing (no error recovery and no ambiguities)
of all Rascal source files in the rascal repo with the speed before this PR. We could not find any speed differences between
the two version, so we are confident this PR does not degrade performance of "normal" parses.