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
[RAR] Stop removing from file cache just because an assembly is cached in process #6891
[RAR] Stop removing from file cache just because an assembly is cached in process #6891
Conversation
This was causing numerous unnecessary cache misses.
src/Tasks/SystemState.cs
Outdated
isDirty = true; | ||
} | ||
|
||
return cachedProcessFileState; | ||
} | ||
// If the process-wide FileState is missing or out-of-date, this instance owns serialization; |
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.
nit: Is this comment still valid?
…m/Forgind/msbuild into stop-removing-from-filestatecache
One extra thought I had: So ComputeFileStateFromCachesAndDisk would look more like:
And we'd remove ReadStateFile and modify WriteStateFile to only write anything if _cache is not null and dirty. Advantage: Less serialization and deserialization, assuming most of the projects use the same assemblies. Note: May also be a bit less relevant with a RARaaS node if it is only expected to read in a state file cache once per build but would be more relevant if the RARaaS node reads in a state file for every RAR execution. Thoughts? |
@Forgind I like the idea of lazy load state file once it is needed. The change seems to be simple and safe. |
Fixes #6844
Context
RAR has several caches, including a process-wide cache and a (serialized) file cache. Previously, we had the process cache take priority (if it was up-to-date) and removed from the serialized cache, believing that meant some other process had taken "ownership" of serializing the assembly, but that doesn't actually make sense because that other process could be the same process currently looking at this assembly, and even if it were another process, that other process could have removed it from its own file cache. This removes that flawed logic so that we always write to the file cache any information we have. This improves incremental build times.
Changes Made
Stopped removing from file cache when process-wide cache has information.
Testing
Tried without this change and noted that the first few attempted cache lookups all missed. Tried with this change without killing processes and noted that they were cache hits; tried with this change after killing processes, and they were still cache hits.
Also noted that without this change, there were 0 things in the instanceLocalFileStateCache at the beginning of the first RAR execution. After it, there were 122.
All tests conducted with Ocelot repo.
Notes
I actually mentioned that I didn't think it made sense to have this code here in the "questions" section of my RAR pre-caching document here but never looked into it more. Ah, well.