-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Reduce ImmutableDictionary allocations in CreateCompilationTrackerMap #70319
Reduce ImmutableDictionary allocations in CreateCompilationTrackerMap #70319
Conversation
ToddGrun
commented
Oct 10, 2023
- No need to create a builder if _projectIdToTrackerMap is empty
- No need to create a new ImmutableDictionary if it would end up having the exact same contents as projectIdToTrackerMap
1) No need to create a builder if _projectIdToTrackerMap is empty 2) No need to create a new ImmutableDictionary if it would end up having the exact same contents as projectIdToTrackerMap
|
||
var newTrackerInfo = ArrayBuilder<KeyValuePair<ProjectId, ICompilationTracker>>.GetInstance(); | ||
var allReused = true; |
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.
Are we better off just doing a loop first checking the dependency graph CanReuse() for each of the entries, and if so just bailing entirely? Otherwise here we're still allocating the builder only to throw it away if that case happens.
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.
From what I've seen, pretty much everything about ImmutableDictionarys are slow, so I figured it was just better to make a single pass through it. The intent here is that the ArrayBuilder won't actually allocate normally, so the only real allocation that will happen is if the ImmutableDictionary really needs to be created.