Skip to content

[Fusion] Read source schema results with the shape that their operation expects - #11043

Merged
michaelstaib merged 7 commits into
mainfrom
perf/fusion-shape-guided-source-results
Nov 22, 2026
Merged

michaelstaib merged 7 commits into
mainfrom
perf/fusion-shape-guided-source-results

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

The gateway writes the operation that it sends to a source schema, so it knows which properties every object of the result has, and it can expect them in the order of the selection set. The GraphQL specification recommends that order but does not require it, so the order is only an expectation that is checked for every object. The result parser now compares the next property name of an object with the expected name as one token, and marks an object that has exactly the expected properties in the expected order. Value completion resolves the properties of a marked object by their position, so it no longer reads and compares their names. An object with other properties (another order, missing or unknown fields, fragments, escaped names) is parsed and completed as before, so results do not change. Batched requests are covered, including a request that merges up to 32 operations. This branch also contains #11044, which appends the parsed rows through a writer that keeps the slot of the next row and the rows left in the current chunk in the locals of the parse method.

Metric Before Optimization After Optimization
Source objects completed by position (benchmark query) 0 of 4,096 4,095 of 4,096
Value completion, share of gateway CPU (AOT profile) 9.47% 7.97%
Parsing source results, share of gateway CPU (AOT profile) 6.58% 7.17%
Parse a 21 KB source result with its expected shape, with #11044 40.61 µs 36.75 µs
Parse a 21 KB source result without an expected shape, with #11044 32.09 µs 28.58 µs
Gateway CPU per request, k6 constant, AOT 0.686 ms 0.682 ms
k6 constant-latency, AOT (req/s, p50 ms, p95 ms) 3,602, 13.14, 17.89 3,600, 13.15, 17.88
k6 constant-latency, JIT (req/s, p50 ms, p95 ms) 3,583, 13.21, 18.11 3,584, 13.23, 18.01
k6 constant, AOT (req/s, p50 ms, p95 ms) 5,271, 8.37, 17.98 5,284, 8.35, 17.92
k6 constant, JIT (req/s, p50 ms, p95 ms) 5,494, 7.99, 17.36 5,484, 7.92, 17.75
k6 burst, AOT (req/s, p50 ms, p95 ms) 4,767, 39.47, 125.92 4,794, 39.64, 125.54
k6 burst, JIT (req/s, p50 ms, p95 ms) 4,880, 38.93, 118.82 4,953, 38.08, 117.48

Measured on the benchmark twin (Ryzen 7 5700G, gateway on 2 cores). Profile rows: inclusive share of value completion and of source result parsing in the on-CPU samples of the Native AOT gateway under the constant load (about 41,500 samples per build, final commit). AOT constant and constant-latency rows: both gateways in turn against the same subgraph processes, final commit, 6 runs per side in constant (after: 5,210 to 5,335 req/s) and 3 in constant-latency. JIT and burst rows: 2 runs per side from separate process starts; the JIT constant and constant-latency rows were measured before the last commit, which only changes how the properties of a merged batch result are matched. CPU per request row: gateway CPU time over a 30 s constant load, mean of 6 process starts before and 20 after (standard error of the difference 0.3%). Throughput is equal within the measurement in every mode, so the profile and CPU rows are the measured effect: about 0.7 to 0.9% of gateway CPU. The object count was taken with temporary counters before the review commits. The gateway response to the benchmark query is byte-identical (87,327 bytes), and the 2,329 Fusion execution tests and 839 Fusion integration tests pass.

The gateway knows the operation that it sends to a source schema, so it knows which properties every object of the result has and in which order. The parser of a source result now compares the next property name of an object with the name that the operation expects as one token, and marks an object that has exactly the expected properties in the expected order. Value completion resolves the properties of a marked object by their position and no longer reads and compares their names. An object with any other properties is read and completed as before.
A batched request can merge the root fields of several operations. Its result is now read with a shape that combines the shapes of these operations, in which an item of the batch is told apart by the name of its root field.
…ound the slow path

The expected shape of a source result is built from the operation document that the plan node already holds and is published once. A property name that the parser reads on its regular path is compared with the next expected field first, so white space before a colon no longer hides the expected shape, and the later expected fields of an object are searched at most until its first unknown name. The shape of a batched request follows from the requests that share its body. The selections of a shape node are kept for at most eight selection sets, after which properties are looked up by name.
…tions

A property of a merged result was compared with the root field of every merged operation from the first one on. The comparison now starts at the field of the property before it, and nothing is expected of a request that merges more than 32 requests or whose root fields read as the alias of an item. Building the merged shape looks at every request once, and a full set of kept shapes is left without taking the lock.
@michaelstaib
michaelstaib merged commit c085ab1 into main Nov 22, 2026
156 of 157 checks passed
@michaelstaib
michaelstaib deleted the perf/fusion-shape-guided-source-results branch November 22, 2026 22:27
michaelstaib added a commit to michaelstaib/graphql-platform that referenced this pull request Nov 23, 2026
* [Website] Fix HTTP response formatter docs for the v16 API (ChilliCream#10951)

* Fix the release failing while installing k6 for the Fusion PGO profile (ChilliCream#10952)

* Fix the AspNetCore tests failing to build for .NET 8 (ChilliCream#10962)

* Rename the Draft20260903 transport version to September2026 (ChilliCream#10963)

* [Fusion] Match fully reused entities on XxHash3 keys and copy producer rows once (ChilliCream#10941)

* Deprecate the Draft20230127 transport version (ChilliCream#10964)

* [Website] Update benchmark results (ChilliCream#10965)

* Enable empty selection sets by default (ChilliCream#10971)

* Add empty selection set support to StrawberryShake (ChilliCream#10972)

* Persist GitHub CLI login across container rebuilds (ChilliCream#10974)

* Fix the Green Donut documentation link in the README (ChilliCream#10973)

* [Fusion] Fix missing operation plan metadata in YAML test snapshot diffs (ChilliCream#10975)

* Use OIDC for Docker Hub login (ChilliCream#10976)

* [Website] Update benchmark results (ChilliCream#10977)

* Coordinate commercial builds and releases (ChilliCream#10970)

* Parallelize repository preparation in prepare-release.sh (ChilliCream#10978)

* Remove the cloud platform update from the release workflow (ChilliCream#10979)

* [Fusion] Reduce allocations on the error path (ChilliCream#10981)

* [Fusion] Fix missing errors for nested shared value types (ChilliCream#10967)

Co-authored-by: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com>

* [Fusion] Fix null propagation for required list items (ChilliCream#10983)

* [Fusion] Fix lookup error paths (ChilliCream#10986)

* [Fusion] Fix missing errors for null required object list items (ChilliCream#10989)

* [Fusion] Fix late subgraph results dropping siblings of nulled objects (ChilliCream#10990)

* [Fusion] Fix late subgraph results reporting false list length mismatches (ChilliCream#10991)

* [Fusion] Fix results with more than 32,767 source documents throwing (ChilliCream#10998)

* [Website] Update npm dependencies to clear advisories (ChilliCream#11002)

* Update .NET SDK to 11.0.100 (ChilliCream#11004)

* [Fusion] Reduce allocations when forwarding errors (ChilliCream#11003)

* [Nitro CLI] Accept Apollo persisted query manifests for client upload/validate (ChilliCream#11005)

* [Mocha] Fix dispatch race during endpoint startup (ChilliCream#11006)

* [Mocha] Fix ExponentialBackoff returning the same delay once it reaches the maximum (ChilliCream#10870)

* [Mocha] Log receive failures and circuit breaker state changes, and fix the conversation ID of the receive span (ChilliCream#10871)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RequestAsync waiting for a dispatch that outlasts the response timeout (ChilliCream#10872)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Report unhealthy transports in the message bus health check and add a timeout (ChilliCream#10873)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Start reply endpoints first, stop them last, and finish cleanup when a stop is cancelled (ChilliCream#10874)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix the Postgres outbox using up the attempts of a message while the transport is unavailable (ChilliCream#10875)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix scheduled messages using up their attempts while the transport is unavailable (ChilliCream#10876)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Prepare the RabbitMQ transport: internal connection types, RabbitMQ.Client 7.2.2, provisioning with the connection, queue defaults (ChilliCream#10877)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Add the RabbitMQ connection manager and failure classification (ChilliCream#10878)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ consumers not attaching again after a channel or connection loss (ChilliCream#10879)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ sends and publishes completing without the broker's confirmation (ChilliCream#10880)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix messages for a missing RabbitMQ queue or exchange being dropped (ChilliCream#10881)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ requests being sent before the reply consumer is attached (ChilliCream#10882)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Move the outbox and scheduler dispatch intervals into their options (ChilliCream#11007)

* Update the .NET 11 packages to the GA release (ChilliCream#11008)

* [Mocha] Fix scalar JSON bodies being cut to their last byte when a stored envelope is read (ChilliCream#11014)

* [Mocha] Fix generated registrations for message types found at publish and send call sites (ChilliCream#11013)

* [Mocha] Fix docs that name APIs and delivery guarantees Mocha does not have (ChilliCream#11015)

* [Mocha] Add UseDispatch, UseReceive and UseConsume to the message bus host builder (ChilliCream#11020)

* Update Aspire and WebUtilities to their patched releases (ChilliCream#11021)

* Set a 7-day NuGet minimum publish age, exempting ChilliCream packages (ChilliCream#11023)

* Replace custom test loggers and clocks with Microsoft testing utilities (ChilliCream#11025)

* [Mocha] Fix saga replies being lost when the sending instance stops (ChilliCream#11022)

* [Fusion] Fix PGO profile handoff to commercial builds (ChilliCream#11027)

* [Fusion] Fix a source schema result staying unreleased when the result callback throws in an alias batch (ChilliCream#11009)

* Fix the fixed-size array pool reserving slots for its largest level up front (ChilliCream#11011)

* Skip unescaping and hashing request documents the parser has seen before (ChilliCream#11010)

* Fix Postgres subscription dispose leaking a connection or hanging (ChilliCream#11026)

* [Mocha] Fix saga replies being discarded when they arrive before the saga state is saved (ChilliCream#11028)

* Snapshot small request feature collections without a frozen dictionary (ChilliCream#10942)

* Fix the cache dropping an entry when a duplicate of its key is evicted (ChilliCream#11039)

* Write the accessed flag of a cache entry only when it is not set (ChilliCream#11040)

* [Fusion] Call Apollo Federation entity lookups without nested async iterators (ChilliCream#11041)

* [Fusion] Read source schema results with the shape that their operation expects (ChilliCream#11043)

* [Website] Add Mocha comparison pages and migration guides (ChilliCream#11024)

* [Fusion] Keep the scratch state of entity lookups per request and build error variable sets on demand (ChilliCream#11042)

* [Fusion] Reference the closed options services of the gateway so Native AOT binaries contain them (ChilliCream#11012)

* [Fusion] Set the operation planner version to 2.13.0

* [Fusion] Update the plan snapshots of the deferred tests to the snapshot format of main

* [Fusion] Fix a sibling field being lost when a late source result has errors below a nulled position

---------

Co-authored-by: Glen <glen.84@gmail.com>
Co-authored-by: Tobias Tengler <45513122+tobias-tengler@users.noreply.github.com>
Co-authored-by: Faris Basha TM <72191505+farisbasha@users.noreply.github.com>
Co-authored-by: vbornand <vbo@netswipe.ch>
Co-authored-by: PascalSenn <senn.pasc@gmail.com>
Co-authored-by: Pascal Senn <pascal@chillicream.com>
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