Skip to content
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

Experiment with targetted perf improvements around Project.Documents. #48682

Closed
CyrusNajmabadi opened this issue Oct 16, 2020 · 1 comment
Closed

Comments

@CyrusNajmabadi
Copy link
Member

From #48597 (comment)

This is primarily caused by an inefficient implementation of Project.Documents. In order of impact (most impactful items first):

  1. Each call to GetDocument produces a call to ContainsDocument, which is slow and unnecessary in this context
  2. ImmutableHashMap<TKey, TValue>.TryGetValue is slow, particularly in the implementation of HashBucket.Get
  3. DocumentIds is implemented with ImmutableList<T>, which has an inefficient enumerator

Options we could potentially take:

  1. Move DocumentIds to be an ImmutablArray. this will make iteration very good, and will also have a nice compact representation. However, it may exhibit poorer behavior if a project is forked many times with lots of changes to the doc array.
  2. GetDocument could have an private implementation that does/doesn't check for containment. .Documents would call the version that doesn't check containment since it can't ever fail.
  3. We could switch the map we use from ImmutableHashMap to dictionary. This may exhibit issues though as we'll need something to lock on (and that could be contentious). We'd also incur an allocation for the lock/dictionary for hte empty case, which we don't have today.

None of these issues may be problematic in practice. But it's not evident up front that they won't be.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 16, 2020
@jinujoseph jinujoseph added Area-Performance Concept-Continuous Improvement and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 20, 2020
@jinujoseph jinujoseph added this to the Backlog milestone Oct 20, 2020
sharwell added a commit to sharwell/roslyn that referenced this issue Jan 12, 2021
@tmat tmat self-assigned this Feb 15, 2021
@tmat tmat modified the milestones: Backlog, 16.10 Feb 15, 2021
@jinujoseph jinujoseph modified the milestones: 16.10, Backlog Jul 16, 2021
@CyrusNajmabadi
Copy link
Member Author

Closing out as speculative.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants