Add fast paths for Fusion forwarded variables and four requirements - #10121
Add fast paths for Fusion forwarded variables and four requirements#10121michaelstaib wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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 asReadOnlySpan<ForwardedVariableValue>. - Refactor
FetchResultStorevariable/representation writers to accept a unifiedForwardedVariableValueswrapper 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.
| private ForwardedVariableValues(int capacity) | ||
| { | ||
| _inline = default; | ||
| _rented = capacity > InlineCapacity | ||
| ? ArrayPool<ForwardedVariableValue>.Shared.Rent(capacity) | ||
| : null; | ||
| _count = 0; |
| 4 => BuildVariableValueSetsFourRequirements( | ||
| elements, | ||
| requestVariables, | ||
| requiredData[0], | ||
| requiredData[1], |
Patch coverage82.4% of changed lines covered (366/444)
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) |
|
|
No description provided.