Skip to content

[Fusion] Hoist object-invariant resolution out of the per-property lookup - #10076

Merged
michaelstaib merged 3 commits into
mainfrom
mst/hoist
Jul 9, 2026
Merged

[Fusion] Hoist object-invariant resolution out of the per-property lookup#10076
michaelstaib merged 3 commits into
mainfrom
mst/hoist

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 9, 2026 17:43

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 composite result object property resolution during execution by hoisting object-invariant work (reference resolution, token-type validation, and selection-set lookup) out of the per-property lookup path, reducing repeated guards and metadata decoding in hot loops.

Changes:

  • Introduce CompositeObjectContext to cache per-object lookup context for repeated property resolution.
  • Add GetObjectContext APIs on CompositeResultElement/CompositeResultDocument to build the cached context once per object.
  • Update ValueCompletion to reuse the cached object context while iterating source object properties.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultElement.cs Adds an internal GetObjectContext() that hoists the per-property validity guard to once-per-object.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.TryGetProperty.cs Adds GetObjectContext(Cursor) and a linear-scan helper to support cached per-object property lookup.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeObjectContext.cs New struct that encapsulates cached object lookup state and provides TryGetProperty without repeated invariant work.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Switches object property resolution to use the cached CompositeObjectContext during completion.

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

Comment on lines +42 to +46
var propertyIndex = selection.Id - selectionSet.Id - 1;
var propertyRowIndex = (propertyIndex * 2) + 1;
var propertyCursor = _objectStartCursor + propertyRowIndex;
value = new CompositeResultElement(_document, propertyCursor + 1);
return true;
@michaelstaib
michaelstaib merged commit e351154 into main Jul 9, 2026
142 of 143 checks passed
@michaelstaib
michaelstaib deleted the mst/hoist branch July 9, 2026 18:11
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.

2 participants