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

ResolverUtility.FindLibraryFromSourcesAsync should cancel pending work when returning early #12665

Open
drewnoakes opened this issue Jun 17, 2023 · 2 comments

Comments

@drewnoakes
Copy link

https://github.com/NuGet/NuGet.Client/blob/3be9ceed93526e7fed1282820436435694f122cd/src/NuGet.Core/NuGet.DependencyResolver.Core/ResolverUtility.cs#L433-L456

This code spins up one Task per IRemoteDependencyProvider and waits for them to complete.

If one of these tasks completes with an exact match, that match is returned immediately.

However in such a case, any pending work is left to complete. From my reading of the code, the result of that work is unused, and therefore those ongoing tasks should be cancelled to avoid wasting resources (IO/CPU/etc).

If that's right, it can be achieved easily with CancellationTokenSource.CreateLinkedTokenSource.

@drewnoakes drewnoakes added the Tenet:Performance Performance issues label Jun 17, 2023
@ghost
Copy link

ghost commented Jun 17, 2023

@drewnoakes Issue is missing Type label, remember to add a Type label

@ghost ghost added the missing-required-type The required type label is missing. label Jun 17, 2023
@ghost ghost removed the missing-required-type The required type label is missing. label Jun 17, 2023
@nkolev92
Copy link
Member

The benefits of that idea are probably varied by scenario.

If you have more than 1 version of a package within that solution, then cancelling a task that might be bringing the 2nd version that's in a project that hasn't been restored yet could have a negative impact.
This would probably require some performance testing like for example: https://github.com/NuGet/NuGet.Client/tree/dev/scripts/perftests

@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. Area:HttpCommunication labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants