Skip to content

Reduce blocking time in UpdateSolution_QueryDelayBuildAction#7454

Merged
nkolev92 merged 5 commits into
devfrom
dev-erarndt-queryDelayBuildAction
Jun 18, 2026
Merged

Reduce blocking time in UpdateSolution_QueryDelayBuildAction#7454
nkolev92 merged 5 commits into
devfrom
dev-erarndt-queryDelayBuildAction

Conversation

@Erarndt

@Erarndt Erarndt commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Bug

Fixes:

Description

Users are reporting that there is an occasional lengthy delay before build starts. Some early telemetry shows that it can take over 10s just to construct the IVsTask that gets returned. This isn't the time to finish the restore that the task initiates.

The code now unconditionally yields as a first step to return to the caller immediately. Additionally, switching to explicit GetExport() calls avoid some of the cost associated with SatisfyImportsOnce(). There might be a few innacuracies here, but it looks like there were some recent exports/services that were added that could explain why the MEF construction is showing up now:

  • CopilotToolInvocationService.cs
  • FixVulnerablitiesService.cs
  • VulnerablePackagesInfoBar.cs (IVulnerabilitiesNotificationService)
  • AuditCheckResultCachingService.cs
  • InfiniteScrollListViewModel
  • LegacyProjectAdapter
  • several PackageSourceMapping options pages

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@Erarndt Erarndt requested a review from a team as a code owner June 4, 2026 16:26
@Erarndt Erarndt requested review from donnie-msft and jebriede June 4, 2026 16:26
@Nigusu-Allehu

Copy link
Copy Markdown
Member

Let's update the PR title

@Erarndt Erarndt changed the title Dev erarndt query delay build action Reduce blocking time in UpdateSolution_QueryDelayBuildAction Jun 4, 2026
@Erarndt

Erarndt commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Let's update the PR title

Updated :)

@donnie-msft donnie-msft left a comment

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.

Is there evidence that this is resolving the issue you described, or is it just something to try and observe its impact?

Had a few questions inline...

Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
@donnie-msft

donnie-msft commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

it looks like there were some recent exports/services that were added that could explain why the MEF construction is showing up now:

I'm not understanding some of the listed items. Such as:

several PackageSourceMapping options pages

I assume this means VS Options pages, such as PackageSourceMapping. There are no MEF imports in this page, but it does rely on VSSettings which comes from a MEF import in NuGet's AsyncPackage in one initial place - NuGetPackage.cs, and it is shared among those settings pages.

Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
Nigusu-Allehu
Nigusu-Allehu previously approved these changes Jun 4, 2026

@Nigusu-Allehu Nigusu-Allehu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Erarndt

Erarndt commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Is there evidence that this is resolving the issue you described, or is it just something to try and observe its impact?

Had a few questions inline...

I do not have a way to reproduce the issue locally, so I can't directly validate the fix. I had to use telemetry to diagnose the issue in the wild.

There are multiple instrumentation points, and the issue I'm attempting to address in this PR is the synchronous blocking in UpdateSolution_QueryDelayBuildAction() before the IVsTask is returned. The duration of the IVsTask completion is captured in a separate telemetry event. The call to RestoreAsync() immediately yields, so it can't be the culprit. There's not much other code here, and the most likely issue is the code in the JTF.Run(). Moving the blocking code into the task is sufficient to avoid the synchronous block.

The change to the import flow isn't required to stop the synchronous blocking, but telemetry indicates that this code is rather slow (taking over 17s in a few instances). This was my attempt at speeding things up.

@Erarndt

Erarndt commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

it looks like there were some recent exports/services that were added that could explain why the MEF construction is showing up now:

I'm not understanding some of the listed items. Such as:

several PackageSourceMapping options pages

I assume this means VS Options pages, such as PackageSourceMapping. There are no MEF imports in this page, but it does rely on VSSettings which comes from a MEF import in NuGet's AsyncPackage in one initial place - NuGetPackage.cs, and it is shared among those settings pages.

It's entirely possible that list is inaccurate. That was a quick attempt to see what might have changed to make this path slower recently. This seems like a relatively new issue, so I took a quick look. I can't reproduce this locally, so I can't profile.

Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
Comment thread src/NuGet.Clients/NuGet.SolutionRestoreManager/SolutionRestoreBuildHandler.cs Outdated
nkolev92
nkolev92 previously approved these changes Jun 11, 2026
@nkolev92

Copy link
Copy Markdown
Member

This needs a rebase on top of latest dev @Erarndt

@Erarndt Erarndt force-pushed the dev-erarndt-queryDelayBuildAction branch from 8bfb473 to 2d67aea Compare June 17, 2026 17:49
@Erarndt

Erarndt commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

This needs a rebase on top of latest dev @Erarndt

Rebased. Looks like the last NuGet.Clinet-VS run had some failures, but the tests history either looks flaky or has been failing consistently across runs. Do you see anything that I introduced?

@nkolev92 nkolev92 merged commit 43f1cda into dev Jun 18, 2026
20 of 21 checks passed
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.

6 participants