-
Notifications
You must be signed in to change notification settings - Fork 786
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 results in incremental build #14852
Conversation
Can we estimate the memory impact of this, e.g. on FCS solution ? |
OK, so A vague idea: |
@majocha |
Thanks I'll take a look. Yeah, I'm running with live buffers because its 2023 after all 🙂. Possibly some problems with excessive parsing that people report are related to that. |
Let's see what breaks. |
I'm making some changes to better grasp the code, I will reduce the diff later. This is slowly taking shape, and feels a bit better when editing with live buffers. Should now work also with the dead ones 🙂. @0101, about the live buffers: When the user types fast it fires a lot of NotifyFileChanged calls. I wonder whether some debounce / cancellation on the client is needed or does the builder deal with it smartly on it's own? |
Calling |
Almost done, let's see if it's still green. |
@majocha This looks good so far. Can I please ask you to make sure that the new behaviour is docummented somewhere under |
OK testing this need some more thought. We should actually count cache hits. |
@T-Gro, I added some tests that actually count cache hits with telemetry. |
Tests done, docs done. This is ready for review when green. |
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.
@majocha thanks for your awesome work. Please also add a resource here, that's for the purpose of searching this setting in the VS options window.
@auduchinok @safesparrow are you fine with merging this?
That is great, thanks for it. I think we should merge and insert it, so we can start testing it. |
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.
This looks really good!
I'm ok with this if it either doesn't make caching other usecases harder in the future (it likely doesn't) or already works for all IDEs including Rider. Last time I tested this it didn't work for Rider, but I didn't test the latest version. |
@safesparrow this should work now for all cases involving incremental builder, whether ISourceText is used or not. There are still cases in VS (Rider probably too) where some |
This looks good, thank you! |
* Cache parsing results in incremental build (#14852) * First take on the F# telemetry (#14889) * Array.Parallel - search functions (tryFindIndex,tryFind,tryPick) (#14827) * Searching functions for Array.Parallel added * with [<Experimental("Experimental library feature, requires '--langversion:preview'")>] annotation to give us space to change/remove this API in the future if needed * Add `GraphNode.FromResult` (#14894) * Add GraphNode.FromResult * fantomas * Fix missing reference (#14892) * Fix missing reference * undo whitespace change --------- Co-authored-by: Jakub Majocha <1760221+majocha@users.noreply.github.com> Co-authored-by: Petr <psfinaki@users.noreply.github.com> Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com> Co-authored-by: Petr Pokorny <petrpokorny@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
FYI: We modified a local Rider instance to use this and we can see the cache being hit in some sequences of user interactions. Taking the Fantomas repository as an example, it can be seen how opening some files is filling up the cache. Especially the files in our |
I tested it in Rider and can see that files in between the modified file and the file that gets opened/checked are not reparsed. There are some other Rider issues/reasons that cause many parsing requests, as described in JetBrains/resharper-fsharp#492 - that might explain the nonconsistent caching behaviour you've seen @dawedawe . But I think the feature is working as expected in the scenario where a chain of files are checked due to a change at the start of the chain. |
Addresses #14848.
In this implementation IncrementalBuilder keeps one most recent result of parsing for each file.
Cached items are removed on source change of corresponding file.
This works the same with live buffers and the normal on disk mechanism.
Memory impact does not look bad, for example FCS solution open in Visual Studio:
note: with
enablePartialTypeChecking
it does not cache files backed with signature.This is not a new feature. In IncrementalBuild.fs there was code for similar caching before, but it stopped functioning at some point, I guess? Probably a good idea to put a small test for this, but I'm not sure how to do it.
This can be toggled in performance settings in VS:
to do: