Skip to content

[Fusion] Reduce metadb row reads in the result merge hot path - #10075

Merged
michaelstaib merged 2 commits into
mainfrom
mst/metadb-reads
Jul 9, 2026
Merged

michaelstaib merged 2 commits into
mainfrom
mst/metadb-reads

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 9, 2026 16:38

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

Reduces metadata DB row reads on the Fusion result-merge hot path by enabling single-row retrieval patterns and in-place meta row updates that preserve parent pointers.

Changes:

  • Added APIs to fetch the underlying parsed/meta row once (SourceResultElement/Document) to avoid repeated reads for token type + range.
  • Introduced ReplacePreserveParent to overwrite meta rows in-place without re-reading the parent pointer.
  • Added TryGetProperty overloads that return both the value element and its Selection to avoid extra selection resolution work in ValueCompletion.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs Adds GetValueRow() to expose the parsed row for reuse.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.Text.cs Adds GetValueRow(Cursor) helper for callers to reuse a single row read.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultElement.cs Adds internal TryGetProperty overload returning Selection.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.TryGetProperty.cs Adds TryGetNamedPropertyValue overload returning Selection alongside the value.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.MetaDb.cs Adds ReplacePreserveParent fast-path overwrite method.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.cs Switches assignments to use ReplacePreserveParent and source row reads.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Uses new property lookup overload to reuse Selection and reduce meta reads.

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

Comment on lines +432 to +437
// int 1: OperationReferenceId + OperationReferenceType + Flags
Unsafe.WriteUnaligned(
ref Unsafe.Add(ref row, DbRow.SelectionAndFlagsOffset),
operationReferenceId
| ((int)operationReferenceType << 15)
| ((int)flags << 17));
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@michaelstaib
michaelstaib merged commit 6a0c17f into main Jul 9, 2026
13 checks passed
@michaelstaib
michaelstaib deleted the mst/metadb-reads branch July 9, 2026 17:23
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