Skip to content

Conversation

@jasonmalinowski
Copy link
Member

If the project system tells us about a file that's open and we are told about it on a background thread, we connect the file to the workspace on that background thread but then schedule work to the UI thread to ensure we correctly connect it to the right context (linked files, shared projects, multitargeting, etc.) That code on the UI thread then acquires the workspace lock, and we're seeing cases in the wild where that lock acquisition is taking longer than we'd like. Although there are deeper fixes we can do there, there's one trivial fix we can make: don't schedule the work to the UI thread unless the file is in at least two projects. Otherwise, we don't actually need to figure out the context in the first place and it's just wasting time.

An entirely unscientific analysis of a handful of traces from users hitting this, there weren't any cases where the file was actually in more than one project, so this should have a nice improvement overall.

Closes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2471561

If the project system tells us about a file that's open and we are told
about it on a background thread, we connect the file to the workspace
on that background thread but then schedule work to the UI thread
to ensure we correctly connect it to the right context (linked files,
shared projects, multitargeting, etc.) That code on the UI thread then
acquires the workspace lock, and we're seeing cases in the wild where
that lock acquisition is taking longer than we'd like. Although there
are deeper fixes we can do there, there's one trivial fix we can
make: don't schedule the work to the UI thread unless the file is in
at least two projects. Otherwise, we don't actually need to figure out
the context in the first place and it's just wasting time.

An entirely unscientific analysis of a handful of traces from users
hitting this, there weren't any cases where the file was actually
in more than one project, so this should have a nice improvement
overall.

Closes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2471561
@jasonmalinowski jasonmalinowski self-assigned this Jun 17, 2025
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner June 17, 2025 23:41
@jasonmalinowski jasonmalinowski merged commit f479243 into dotnet:main Jun 18, 2025
26 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 18, 2025
CyrusNajmabadi added a commit to CyrusNajmabadi/roslyn that referenced this pull request Jun 18, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants