-
Notifications
You must be signed in to change notification settings - Fork 259
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
Cache parsing #4085
Cache parsing #4085
Conversation
…eDefinition into Program
… pureParseFunction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed the first 30 files (as they appear in the diff view) - that's up to and including Source/DafnyLanguageServer/Caching/TextReaderFromCharArrays.cs
. I'll continue reviewing the rest.
var array = arrays[arrayIndex]; | ||
if (elementIndex == array.Length) { | ||
return -1; | ||
} | ||
var result = array[elementIndex++]; | ||
if (array.Length == elementIndex) { | ||
arrayIndex++; | ||
elementIndex = 0; | ||
} | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this Read
implementation won't work as expected if there's an empty char[]
anywhere in arrays
(except perhaps at the end). Is that intentional, and if so can we document that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another batch of comments. Just TickingCache
and CachingParser
left to review.
Co-authored-by: Alex Chew <alex-chew@users.noreply.github.com>
Co-authored-by: Alex Chew <alex-chew@users.noreply.github.com>
Most of the changes LGTM. The remaining blocking issues are:
|
Co-authored-by: Alex Chew <alex-chew@users.noreply.github.com>
Co-authored-by: Alex Chew <alex-chew@users.noreply.github.com>
Changes
Caveats
I've decided not to add an option to turn off caching, since I don't see the use-case. Of course caching is a computation vs storage trade-off, and we could provide many options to configure the caching behavior, but I think the current caching is cheap enough (at most storing two sets of parse results at a time) that there is no reason to want to turn it off.
Please carefully review the code that determines the cache key, since a bug in that would lead to outdated compilation results.
Testing
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.