Repository navigation
[Fusion] Complete subgraph responses at the end of the JSON root - #10847
Merged
Merged
Conversation
With chunked transfer encoding, a source schema writes the terminating chunk when its response completes, often in a later segment than the body, and the gateway read every chunked body to its end. The arena read now finds the end of the root object or array as bytes arrive and stops once the root ended and only whitespace followed it in the same read. Disposing the content stream lets the handler drain the rest of the body, which keeps the connection reusable. The root end is found with 64-byte vector masks.
On HTTP/2 and HTTP/3, disposing an unfinished response stream resets it, so the source schema sees the request as aborted. Those responses now read to the end of the body. The trailing-data test now awaits the read directly, and long documents whose root does not end cover the vectorized scanner path.
Contributor
Patch coverage100.0% of changed lines covered (169/169)
Project coverage: 59.5% (322222/541481 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.
Subgraphs send chunked responses, and the gateway waited for the final empty chunk before parsing, even when the JSON was already complete, which cost about 0.23 ms per request on the critical path. On HTTP/1.x the gateway now notices when the JSON root has ended and stops reading there, and the HTTP handler drains the rest when the response is disposed, so the connection stays reusable. HTTP/2 and HTTP/3 responses still read to the end of the body, because disposing an unfinished stream there resets it and the subgraph would see the request as aborted. Finding the end of the JSON uses a vectorized scan that takes about 12 us for the 87 KB benchmark response, and together with the drain it raises CPU per request by about 0.03 ms in exchange for the lower latency.
Measured on the benchmark twin with the official 16.7.0 subgraphs over HTTP/1.1 and the official gateway settings (alias batching, inline scheduling and inline socket completions), before is 592c379, after is this change on top of it without the HTTP/1.x restriction, which leaves the HTTP/1.1 path unchanged; means of 2-3 interleaved rounds with 40 s warm-up and 45 s measured, responses byte-identical.