Skip to content

Use async service provider in ServiceLocator - #2898

Merged
nkolev92 merged 4 commits into
devfrom
dev-nkolev92-useAsyncServiceProvider
Jun 27, 2019
Merged

nkolev92 merged 4 commits into
devfrom
dev-nkolev92-useAsyncServiceProvider

Conversation

@nkolev92

@nkolev92 nkolev92 commented Jun 20, 2019

Copy link
Copy Markdown
Member

Bug

Fixes: 899473
Regression: No

  • Last working version:
  • How are we preventing it in future:

Fix

Details:

From the issue:

GetComponentModelServiceAsync which actually just switches to the UI thread and then calls GetService. This is REALLY bad for MEF which can be very expensive to initialize. NuGet needs to use the async service provider which is MUCH smarter about only switching if needed, ensuring packages that need to be loaded and can be loaded off the UI thread are, etc...

The NuGetPackage is already async and we use the IAsyncServiceProvider in some other related codepaths.
#2163 & #2179

@dtivel This is the change that would conflict with the change in your PR.

Testing/Validation

Tests Added: No
Reason for not adding tests: Threading changes
Validation:

@nkolev92
nkolev92 force-pushed the dev-nkolev92-useAsyncServiceProvider branch from f3ed7fd to 49c34e7 Compare June 21, 2019 00:14
@nkolev92
nkolev92 marked this pull request as ready for review June 21, 2019 01:01
Comment thread src/NuGet.Clients/NuGet.VisualStudio.Common/ServiceLocator.cs Outdated
@nkolev92
nkolev92 requested a review from dtivel June 21, 2019 22:32
@nkolev92
nkolev92 force-pushed the dev-nkolev92-useAsyncServiceProvider branch from 5dbba5f to a1f98b3 Compare June 24, 2019 17:50
@nkolev92

Copy link
Copy Markdown
Member Author

@dtivel this is ready for another review.

@nkolev92
nkolev92 force-pushed the dev-nkolev92-useAsyncServiceProvider branch from 1b1b2df to f6df873 Compare June 27, 2019 19:37
}
}

return Package.GetGlobalService(typeof(TService)) as TInterface;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add telemetry for when this or this is called?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What would be trying to learn?
It would just tell us that the service in question is not async.

Maybe something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dtivel

I'll merge this now, so it can runt through the nightly validations, but i'll be hpapy to discuss further improvements to this.

@nkolev92
nkolev92 merged commit 7ad7355 into dev Jun 27, 2019
@nkolev92
nkolev92 deleted the dev-nkolev92-useAsyncServiceProvider branch June 27, 2019 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants