Skip to content

[Fusion] Hold result document chunks at 16 KB before they grow further - #11047

Merged
michaelstaib merged 9 commits into
mainfrom
perf/fusion-result-chunk-schedule
Nov 24, 2026
Merged

michaelstaib merged 9 commits into
mainfrom
perf/fusion-result-chunk-schedule

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Result documents and source result documents doubled their chunk size with every chunk up to 128 KB, so a document of a few hundred KB already rented 64 KB and 128 KB chunks, and the 128 KB chunks live on the large object heap. The chunk sizes of composite rows, source rows and source data now follow one schedule: 1, 2, 4, 8 and 16 KB, seven more chunks of 16 KB, four of 32 KB, two of 64 KB, then 128 KB. Cursor layouts are unchanged. A source result document now takes up to 44,573,956 rows and 534,920,192 bytes (44,670,892 and 536,083,456 before), and one that needs more row chunks than a cursor addresses fails with the error of a document that is too large.

Metric Before Optimization After Optimization
Large object heap under constant-latency load 19.8 MB 10.6 MB
Resident memory at the end of a constant run 108.1 MB 91.4 MB
Resident memory at the end of a constant-latency run 111.4 MB 101.0 MB
k6 constant-latency, AOT (req/s, p50 ms, p95 ms) 3,580, 13.23, 18.04 3,575, 13.26, 18.01
k6 constant-latency, JIT (req/s, p50 ms, p95 ms) 3,561, 13.31, 18.17 3,553, 13.34, 18.25
k6 constant, AOT (req/s, p50 ms, p95 ms) 5,385, 8.14, 17.72 5,381, 8.13, 17.80
k6 constant, JIT (req/s, p50 ms, p95 ms) 5,510, 7.89, 17.53 5,510, 7.87, 17.63

Benchmark twin (Ryzen 7 5700G, gateway on 2 cores), Apollo Federation subgraphs, Native AOT on .NET 11 unless a row says JIT. Before is the combined branch, after is the combined branch with this change alone. Constant-latency: in AOT both gateways in turn against the same subgraph processes with 3 runs per side, in JIT 4 runs from two process starts per side. Constant: 5 process starts before and 3 after (5,337, 5,381 and 5,471 req/s). Large object heap row: collector statistics of a diagnostics build under load.

Result documents and source result documents doubled their chunk size
with every chunk up to 128 KB, so a document of a few hundred KB already
rented 64 KB and 128 KB chunks. The chunk sizes now follow one schedule:
1, 2, 4, 8 and 16 KB, seven more chunks of 16 KB, four of 32 KB, two of
64 KB, then 128 KB.
The stack trace in the snapshots of Source_Schema_Transport_Error names GraphQLHttpResponse.ReadAsResultAsync with its parameters, and the overload that the source schema client calls takes the expected result shape since the shape guided result reading.
The comments of the result document cursors, the data locations and the chunk schedule say what the bits and the tables hold. Comparisons with the earlier layout and notes on how a value is computed are removed.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

96.0% of changed lines covered (72/75)

File Covered Changed Patch %
…/src/Fusion.Execution/Text/Json/SourceResultDocument.cs 7 10 70.0% 🔴
…/Fusion/src/Fusion.Execution/Text/Json/ChunkSchedule.cs 12 12 100.0% 🟢
…/Fusion.Execution/Text/Json/CompositeResultDocument.Cursor.cs 16 16 100.0% 🟢
…/Fusion.Execution/Text/Json/SourceResultDocument.Cursor.cs 23 23 100.0% 🟢
…/Fusion.Execution/Text/Json/SourceResultDocument.MetaDb.cs 14 14 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "bbaabb23427075ec9aa77d30f31c363adada909a",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.cs", "ranges": [[88, 88], [100, 101]] }
  ]
}

Project coverage: 60.1% (330819/550376 lines)

@michaelstaib
michaelstaib merged commit dab83e3 into main Nov 24, 2026
6 of 7 checks passed
@michaelstaib
michaelstaib deleted the perf/fusion-result-chunk-schedule branch November 24, 2026 06:42
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.

1 participant