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

Fix race with boosting OOP priority. Also, ensure FindRef calls are boosted. #20174

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jun 12, 2017

No description provided.

@CyrusNajmabadi
Copy link
Member Author

Tagging @dotnet/roslyn-ide @heejaechang @Pilchie

easier to review as: https://github.com/dotnet/roslyn/pull/20174/files?w=1

@CyrusNajmabadi
Copy link
Member Author

Previous code would manipulate a value, then set state according to that value. However, nothing was ensuring that this happened atomically. Making it possible for code to need to be boosted, but end up unboosted.

Unboosted code that is invoked by a user is not good. It may take a long itme to run if VS is using the available CPU cycles, and the OOP process gets almost nothing due to it running below-normal pri by default.

@heejaechang
Copy link
Contributor

@CyrusNajmabadi thank you for fix this. my bad!


private static void Start()
{
var value = Interlocked.Increment(ref s_count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this is actually a bug.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count is fine. changing priority can be reordered and run in reverse order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, we could have the following:

BG code is running (refcount is 1).
BG code ends, drops ref count to 0.
User code runs, increases refcount to 1.
User code sets priority to normal
BG code now runs and sets priority to low.

@CyrusNajmabadi
Copy link
Member Author

Tagging @MattGertz

Customer scenario

Some user-invoked OOP operations make take much longer if VS is using a lot of CPU. Because VS and OOP have to share the same CPU resources and OOP runs 'below normal priority' by default, then work in the OOP process may starve while VS is consuming lots of CPU. As these are user-invoked features, that's a very detrimental user experience as tehy may be waiting a long time for their results to appear.

Bugs this fixes:

N/A.

Workarounds, if any

None.

Risk

Low.

Performance impact

user observable performance improves.

Is this a regression from a previous update?

Yes (if you turn on OOP).

Root cause analysis:

The OOP system runs low-priority by default to keep the OOP server from negatively impacting VS while it's just doing background work. However, if OOP is doing work explicitly requested by the user (like Navigate-To/FindRefs/etc.) then we 'boost' the priority to 'normal' so that the OOP server gets a reasonable amount of CPU time.

A race condition in this 'boost' code made it so that the OOP code might not actually happen, leading to OOP running low priority even when working to do a user request.

How was the bug found?

Dogfooding.

@CyrusNajmabadi CyrusNajmabadi merged commit 7e12abb into dotnet:master Jun 13, 2017
@CyrusNajmabadi CyrusNajmabadi deleted the oopPriority branch June 13, 2017 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants