Skip to content

Add fast paths for Fusion forwarded variables and four requirements - #10121

Open
michaelstaib wants to merge 5 commits into
mainfrom
mst/fusion-variable-fastpaths
Open

Add fast paths for Fusion forwarded variables and four requirements#10121
michaelstaib wants to merge 5 commits into
mainfrom
mst/fusion-variable-fastpaths

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 17, 2026 11:22

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.

Pull request overview

This PR optimizes Fusion execution variable-materialization by avoiding ObjectFieldNode allocations for forwarded variables (resolving them once into a span-backed buffer) and extends the existing requirement “fast path” logic to cover the 4-requirement case.

Changes:

  • Add a pooled, inline-capacity resolver (ForwardedVariableValues.Resolve) to materialize forwarded variables as ReadOnlySpan<ForwardedVariableValue>.
  • Refactor FetchResultStore variable/representation writers to accept a unified ForwardedVariableValues wrapper and write forwarded variables via a shared helper.
  • Add fast/slow paths for building variable value sets with exactly 4 requirements.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.RepresentationValue.cs Refactors representation variable creation to support span-resolved forwarded variables and reuse shared forwarded-variable writer.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.ForwardedVariableValues.cs Introduces a FetchResultStore-scoped wrapper that can represent either direct span-resolved variables or ObjectFieldNode lists.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs Adds 4-requirement fast paths and centralizes forwarded-variable writing through WriteForwardedVariableValues.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.cs Switches execution to span-resolved forwarded variables and adds the pooled resolver (ForwardedVariableValues / ForwardedVariableValue).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1002 to +1008
private ForwardedVariableValues(int capacity)
{
_inline = default;
_rented = capacity > InlineCapacity
? ArrayPool<ForwardedVariableValue>.Shared.Rent(capacity)
: null;
_count = 0;
Comment on lines +1150 to +1154
4 => BuildVariableValueSetsFourRequirements(
elements,
requestVariables,
requiredData[0],
requiredData[1],
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

82.4% of changed lines covered (366/444)

File Covered Changed Patch %
…/Execution/Results/FetchResultStore.RepresentationValue.cs 36 50 72.0% 🔴
…/src/Fusion.Execution/Execution/OperationPlanContext.cs 77 99 77.8% 🔴
…/src/Fusion.Execution/Execution/Results/FetchResultStore.cs 240 282 85.1% 🟡
…/Results/FetchResultStore.ForwardedVariableValues.cs 13 13 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "30f737d21614c07634d62e1e4c43860b848c4a16",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.RepresentationValue.cs", "ranges": [[172, 173], [236, 242], [257, 258], [264, 266]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.cs", "ranges": [[425, 431], [460, 462], [465, 465], [486, 487], [489, 489], [517, 519], [522, 522], [1065, 1068]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs", "ranges": [[751, 754], [791, 795], [814, 817], [910, 913], [917, 918], [924, 926], [1185, 1185], [1555, 1555], [1655, 1655], [1786, 1787], [1794, 1795], [1802, 1803], [1881, 1883], [1895, 1897], [1909, 1911], [1937, 1938]] }
  ]
}

Project coverage: 53.8% (231988/430948 lines)

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ michaelstaib
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

4 participants