Skip to content

[Fusion] Copy completed leaf values into duplicate lookup targets - #10612

Merged
michaelstaib merged 4 commits into
mainfrom
tte/fusion-copy-duplicate-lookup-leaf-values
Oct 21, 2026
Merged

michaelstaib merged 4 commits into
mainfrom
tte/fusion-copy-duplicate-lookup-leaf-values

Conversation

@tobias-tengler

@tobias-tengler tobias-tengler commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

When several lookup targets have the same requirement values, the gateway sends one variable set and merges its result into the primary target and every additional target. For the federation benchmark query this means 324 lookup targets but only 7 distinct variable sets, and each duplicate target re-runs path building, variable writing and the full merge (value completion) of the same source data.

This PR completes the primary target once and copies the completed rows into each additional target with the same selection set, as long as every completed value is a non-null, non-enum leaf. Targets with a different selection set, merges with errors and pocketed errors keep the existing per-target completion.

Benchmark query Version Mean Error Ratio
composite-schema main 426.2 µs 7.71 µs 1.00
composite-schema PR 430.1 µs 7.83 µs 1.01
apollo-federation main 435.4 µs 7.59 µs 1.00
apollo-federation PR 417.6 µs 7.17 µs 0.96

The benchmark runs the whole federation benchmark query through the gateway executor against canned subgraph responses. The apollo-federation request is 4% faster, beyond the error interval; composite-schema is unchanged within the error interval. The end-to-end numbers for this change together with #10613 are in #10613.

When one lookup result is merged into a primary target and several additional
targets, the primary target is completed from the source data and, when every
completed value is a non-null, non-enum leaf of an object with the same
selection set, the completed rows are copied into each additional target
instead of completing the same source data again. Targets that do not qualify,
merges with errors and pocketed errors keep the existing completion.
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

79.4% of changed lines covered (85/107)

File Covered Changed Patch %
…/Execution/Results/FetchResultStore.Pooling.cs 1 4 25.0% 🔴
…/src/Fusion.Execution/Execution/Results/FetchResultStore.cs 84 103 81.6% 🟡
Uncovered changed lines (JSON)
{
  "sha": "0997fe14af5f6a6842fe77f6f112d03dbacce953",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.Pooling.cs", "ranges": [[162, 164]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs", "ranges": [[729, 730], [750, 751], [759, 759], [777, 778], [787, 788], [821, 822], [866, 867], [873, 874], [881, 882], [913, 914]] }
  ]
}

Project coverage: 59.2% (313339/529695 lines)

Duplicate targets now take the completed leaf values of the primary target
through TryAssignLeafValue, the leaf copy that entity reuse uses, so targets
at different paths with different selection sets are covered as well.
Targets that cannot take the values (non-scalar source data, alias mappings,
errors, pocketed errors, uninitialized or abstract targets, enum type
mismatches) are completed from the source data. This removes the row
offset copy and its document helpers.
@michaelstaib
michaelstaib marked this pull request as ready for review October 21, 2026 02:16
…ield

The leaf copy assumed that the primary target selects every property of the
source data. A batch whose additional targets select more fields than the
primary left those fields uncompleted on the additional targets. Copying now
stops when the primary does not select a source property, and every target
is completed from the source data.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 03:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@michaelstaib
michaelstaib merged commit 1bf4382 into main Oct 21, 2026
158 checks passed
@michaelstaib
michaelstaib deleted the tte/fusion-copy-duplicate-lookup-leaf-values branch October 21, 2026 03:56
michaelstaib added a commit that referenced this pull request Oct 21, 2026
Resolves the duplicate lookup target copy from #10612 onto cursor targets:
the leaf copy and entity reuse read additional targets through
AdditionalTargets, and TryAssignLeafValue tracks structure replacements like
the other value writers. Drops the row offset copy helpers that #10612 no
longer uses.
michaelstaib added a commit that referenced this pull request Oct 21, 2026
Takes main's duplicate lookup target copy (#10612) and target cursors
(#10613) and keeps this branch's raw leaf key matching on top. The element
overload of TryCreateVariableValues reports the dedup index again for the
leaf key registration.
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.

3 participants