Skip to content

[Fusion] Pool the request cancellation source across operation executions#10080

Merged
michaelstaib merged 2 commits into
mainfrom
mst/cts-reuse
Jul 10, 2026
Merged

[Fusion] Pool the request cancellation source across operation executions#10080
michaelstaib merged 2 commits into
mainfrom
mst/cts-reuse

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 10, 2026 07:53

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 reduces per-request allocations in Fusion execution by reusing a pooled CancellationTokenSource to control (halt) the execution engine without cancelling the overall request pipeline, while still propagating request cancellation (client abort / shutdown) into the engine.

Changes:

  • Reworked OperationPlanExecutor.ExecuteAsync to rent/return a pooled engine CancellationTokenSource and dispose the request-token registration safely.
  • Added pooled engine cancellation management to OperationPlanContext (RentEngineCancellation / ReturnEngineCancellation) and ensured it’s disposed when a context is destroyed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanExecutor.cs Uses a pooled engine CTS + request-token registration with a try/finally to guarantee proper cleanup/reset.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.Pooling.cs Introduces a reusable engine CTS on the pooled context, with reset/replace logic and disposal on context destruction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants