Repository navigation
[Fusion] Reuse request timeout sources in the timeout middleware - #10622
Closed
tobias-tengler wants to merge 1 commit into
Closed
tobias-tengler wants to merge 1 commit into
tobias-tengler wants to merge 1 commit into
Conversation
The timeout middleware created a timeout CancellationTokenSource with its own timer and a linked source over request abort, timeout and schema shutdown for every request. It now rents a pooled RequestTimeoutSource that keeps one timer and registers the schema shutdown token once, so a request only registers on its abort token. The timeout keeps its own flag, so a request abort or schema shutdown is still not reported as a timeout.
This was referenced Oct 19, 2026
Contributor
Patch coverage97.3% of changed lines covered (71/73)
Uncovered changed lines (JSON){
"sha": "933d7ef799b4693f2adec4025a8700c0498f48a1",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Pipeline/RequestTimeoutSource.cs", "ranges": [[121, 122]] }
]
}Project coverage: 59.0% (311605/527913 lines) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For every request, the Fusion timeout middleware creates a timeout
CancellationTokenSourcewith its own timer, a linked source over request abort, timeout and schema shutdown, and a registration on the schema shutdown token, which all requests share.This PR rents a pooled
RequestTimeoutSourcethat keeps one token source and one timer and registers on the schema shutdown token once, so a request only registers on its abort token and arms and disarms the timer. The timeout keeps its own flag, so a request abort or schema shutdown is still not reported as a timeout, and a timer callback dispatched for an earlier request cannot cancel a later one. Streams keep the source until their cleanup as before.Allocations per request from an allocation probe: a
TestServergateway answers a{ value }POST through an in-process source schema handler that yields once, 20,000 sequential requests after 5,000 warmup requests,GC.GetTotalAllocatedBytes(precise: true)across all threads (client, server, gateway and source handler), two rounds. The probe ran with the series applied cumulatively onmain, so the before row ismainwith #10618, #10619, #10620 and #10621.For context, the k6
constantscreen of this change together with the other request pipeline changes (#10618, #10619, #10620, #10621 and #10623) and one further change that is not proposed, A B B A per gateway (3 × 30 s runs per invocation). RPS is the median of the six runs, CPU per request the mean of the six runs, p95 and p99 are per invocation.mainmainThe change saves about 556 B per request, far beyond the probe's run-to-run noise of about ±50 B, and requests no longer register on the shared schema shutdown token. The bundle shows no regression: RPS (−27 and −5), CPU per request (−0.76% and −0.58%) and latency all stay within the A/A noise measured on
main(σ about 65 RPS for the composite schema gateway and 40 RPS for the Apollo Federation gateway, CPU per request CV 0.5 to 0.8%), so the end-to-end gain is not measurable on its own.