Repository navigation
[Fusion] Write minimized results without per-token JsonWriter calls - #10617
Merged
Merged
Conversation
The composite result is written straight into the response buffer when the writer neither indents nor omits nulls. Property names come from a token cached on the selection that already holds the quotes and the colon, so no name is checked for escaping, and every token is placed through one cached span.
Contributor
Patch coverage91.5% of changed lines covered (367/401)
Uncovered changed lines (JSON){
"sha": "9b0ec888e8188e0e2c908c03d6c765248e17dc9c",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/ThrowHelper.cs", "ranges": [[45, 45]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/MinimizedJsonEmitter.cs", "ranges": [[116, 116], [120, 122], [124, 127], [129, 135], [143, 147], [182, 183]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.WriteTo.cs", "ranges": [[335, 337], [341, 341], [362, 364]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.WriteTo.cs", "ranges": [[152, 152], [165, 166], [250, 250]] }
]
}Project coverage: 59.2% (314259/530629 lines) |
michaelstaib
marked this pull request as ready for review
October 22, 2026 02:28
michaelstaib
approved these changes
Oct 22, 2026
This was referenced Oct 25, 2026
Merged
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.
The composite result is serialized through one
JsonWritercall per token, even when the output is minimized. Every property name goes through an escape check, length validation and its ownGetSpan/Advancepair, although response names never need escaping.This PR writes minimized results (no indentation, no null omission, default or relaxed encoder) straight into the response buffer through a cached span. Property names come from a token cached on the selection that already holds the quotes and the colon, and source leaves and source-owned JSON scalars are copied as raw bytes. Indented output, null omission and custom encoders keep the existing
JsonWriterpath. The output is byte-identical, and new tests compare both paths on composed gateway results.maink6
constantscenario, A B B A per gateway (3 × 30 s runs per invocation; values are the mean of the per-invocation medians). The first composite schema invocation of the PR was discarded: in all three of its runs the gateway, subgraph and k6 cores all idled at about half their usual load while latency doubled, which points to an external stall, so the composite PR column is the second invocation only.mainmainGateway CPU per request drops by 2.8% on both gateways, well beyond the run-to-run noise measured on
main(CPU per request CV about 0.5% for the composite schema gateway and 0.2% for the Apollo Federation gateway). The RPS gains (+158 and +65) are not significant on their own given that noise (σ about 65 RPS for the composite schema gateway, 40 RPS for the Apollo Federation gateway), and latency is unchanged within noise.