roslyn
roslyn copied to clipboard
Reduce ImmutableDictionary allocations under SolutionCompilationState by using ImmutableSegmentedDictionary
The _projectIdToTrackerMap member is heavily indicted in the non-devenv allocations in the CompletionTest.Completions speedometer test (over 1 GB of allocations).
As this member is private, we have the ability to tweak this to not be an ImmutableDictionary.
This PR is an attempt to see if switching to ImmutableSegmentedDictionary is advantageous (at the suggestion of Sam). It also keeps changes from an earlier PR that allows callers to CreateCompilationTrackerMap to modify the dictionary data used to create the resultant ImmutableSegmentedDictionary.
*** Speedometer profile excerpt: before changes ***
@333fred -- There is a change under compilers in this PR. However, I didn't end up using the refactored method (as the ImmutableSegmentedDictionary code can't reference that level). I think the change makes the modified method in compilers a bit cleaner, and it might be nice to expose such a method, but I can revert that part of the change if you'd prefer for that to not be included.
Based on speedometer results, moving this out of draft status. @sharwell / @CyrusNajmabadi, ptal. @sharwell -- would like to push for taking the ImmutableSegmentedDictionary as part of this PR, and work with you on determining if a followup PR would be good in that area.
Test insertion PR here Speedometer results: here
Speedometer: Test method: CompletionTest.Completion Scenario: 9990.Totals Counter: CLR_BytesAllocated_NonDevenv
Original: ~1.9 GB allocated under SolutionCompilationState.UpdateDocumentState New: ~500 MB allocated under SolutionCompilationState.UpdateDocumentState
I can look at the compilation tracker part tomorrow!
@ToddGrun let's keep it out; I'd ask you to depend on TryGetNonEnumeratedCount on the appropriate TFMs anyways, so it's not like it would be an immediate no-feedback approval anyways.
Done with review pass for changes under Compilers (commit 5)