Skip to content

Force async execution of resource startup - #10359

Merged
David Fowler (davidfowl) merged 1 commit into
mainfrom
davidfowl/force-async-execution
Jul 13, 2025
Merged

Force async execution of resource startup#10359
David Fowler (davidfowl) merged 1 commit into
mainfrom
davidfowl/force-async-execution

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Jul 13, 2025

Copy link
Copy Markdown
Contributor

Follow up to #10354

  • Previously we didn't preemptively dispatch to the threadpool per resource on startup. That causes issues blocking other resource's startup because of a single blocking call. This change dispatching preemptively before creating the dcp resource.

Reproduced while dogfooding the community toolkit with 9.4 builds. Verified this fix on the same build.

Hanging stack:

hangstack

- Previously we didn't preemptively dispatch to the threadpool per resource on startup. That causes issues blocking other resource's startup because of a single blocking call. This change dispatching preemptively before creating the dcp resource.

Copilot AI 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.

Pull Request Overview

This PR ensures that each resource startup dispatches asynchronously to avoid blocking other resources by preemptively yielding to the thread pool.

  • Inserted Task.Yield() at the start of CreateExecutableAsync to force asynchronous execution.
  • Inserted Task.Yield() at the start of CreateContainerAsync to force asynchronous execution.
Comments suppressed due to low confidence (2)

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1100

  • [nitpick] Consider elaborating this comment to explain why Task.Yield() is necessary to prevent blocking other resource startups (e.g., avoiding thread-pool starvation).
        // Force async execution

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1354

  • [nitpick] Consider expanding this comment to detail the rationale for forcing an asynchronous yield here, so future readers understand the threading implications.
        // Force async execution

@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jul 13, 2025
@davidfowl

Copy link
Copy Markdown
Contributor Author

/backport to release/9.4

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16244106437

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants