Repository navigation
[Fusion] Complete subgraph responses at the end of the JSON root - #131
Closed
michaelstaib wants to merge 1 commit into
Closed
michaelstaib wants to merge 1 commit into
michaelstaib wants to merge 1 commit into
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.
Owner
Author
|
Moved upstream to ChilliCream#10847, rebased on current main and with the Codex review fixes: early completion is limited to HTTP/1.x, the trailing-data test awaits the read directly, and long documents cover the vectorized scanner path. |
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. 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. Finding the end of the JSON uses a vectorized scan that takes about 12 us for the 87 KB benchmark response. The scan and the drain raise 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 and the official gateway settings (alias batching, inline scheduling and inline socket completions), before is upstream 592c379, after is this change on top of it, means of 2-3 interleaved rounds with 40 s warm-up and 45 s measured, responses byte-identical.