Uh oh!
There was an error while loading. Please reload this page.
Cache parsing results in incremental build - #14852
Conversation
T-Gro
commented
Mar 6, 2023
Can we estimate the memory impact of this, e.g. on FCS solution ? |
majocha
commented
Mar 6, 2023
OK, so A vague idea: |
0101
commented
Mar 7, 2023
@majocha |
majocha
commented
Mar 7, 2023
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. |
majocha
commented
Mar 7, 2023
Let's see what breaks. |
majocha
commented
Mar 8, 2023
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? |
0101
commented
Mar 8, 2023
Calling |
Uh oh!
There was an error while loading. Please reload this page.
majocha
commented
Mar 8, 2023
Almost done, let's see if it's still green. |
vzarytovskii
commented
Mar 8, 2023
@majocha This looks good so far. Can I please ask you to make sure that the new behaviour is docummented somewhere under |
majocha
commented
Mar 10, 2023
OK testing this need some more thought. We should actually count cache hits. |
majocha
commented
Mar 10, 2023
@T-Gro, I added some tests that actually count cache hits with telemetry. |
Uh oh!
There was an error while loading. Please reload this page.
majocha
commented
Mar 10, 2023
Tests done, docs done. This is ready for review when green. |
psfinaki
left a comment
There was a problem hiding this comment.
@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?
vzarytovskii
commented
Mar 13, 2023
That is great, thanks for it. I think we should merge and insert it, so we can start testing it. |
Uh oh!
There was an error while loading. Please reload this page.
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. |
majocha
commented
Mar 13, 2023
majocha
commented
Mar 13, 2023
@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 |
T-Gro
commented
Mar 14, 2023
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>
dawedawe
commented
Mar 15, 2023
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 |
safesparrow
commented
Mar 17, 2023
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
enablePartialTypeCheckingit 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: