ResolverUtility.FindLibraryFromSourcesAsync should cancel pending work when returning early #12665
Labels
Area:HttpCommunication
Functionality:Restore
Priority:2
Issues for the current backlog.
Tenet:Performance
Performance issues
Type:Bug
https://github.com/NuGet/NuGet.Client/blob/3be9ceed93526e7fed1282820436435694f122cd/src/NuGet.Core/NuGet.DependencyResolver.Core/ResolverUtility.cs#L433-L456
This code spins up one
Task
perIRemoteDependencyProvider
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
.The text was updated successfully, but these errors were encountered: