-
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
Open
PieterOlivier
wants to merge
18
commits into
feat/error-recovery
Choose a base branch
from
recovery/safe-memoization
base: feat/error-recovery
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.