Skip to content

[Fusion] Perfomance Optimizations#10073

Merged
michaelstaib merged 3 commits into
mainfrom
mst/perf-080726
Jul 8, 2026
Merged

[Fusion] Perfomance Optimizations#10073
michaelstaib merged 3 commits into
mainfrom
mst/perf-080726

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 8, 2026 21:23

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 focuses on performance optimizations in the Fusion execution layer, primarily around reducing overhead when reading metadb rows and building paths during result traversal.

Changes:

  • Replaced several MemoryMarshal.Read/span-slice reads in CompositeResultDocument.MetaDb with Unsafe.ReadUnaligned + direct row-byref access.
  • Added [SkipLocalsInit] to CreateCompactPath to reduce stack zeroing overhead with stackalloc buffers.
  • Enabled unsafe blocks for the Fusion.Execution project and adjusted ExecutionState.Reset() to clear a ConcurrentQueue by draining it.

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/CompositeResultDocument.MetaDb.cs Introduces RowRef and switches multiple row-field reads to Unsafe.ReadUnaligned for faster access.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.cs Applies [SkipLocalsInit] to CreateCompactPath to reduce stack initialization costs.
src/HotChocolate/Fusion/src/Fusion.Execution/HotChocolate.Fusion.Execution.csproj Enables <AllowUnsafeBlocks>true</AllowUnsafeBlocks> for the project.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ExecutionState.cs Replaces queue clearing with a dequeue loop to reset completed results.

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

Comment on lines +593 to +599
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private readonly ref byte RowRef(Cursor cursor)
{
var chunk = _chunks[cursor.Chunk];
ref var data = ref MemoryMarshal.GetArrayDataReference(chunk.Buffer);
return ref Unsafe.Add(ref data, chunk.Offset + cursor.ByteOffset);
}
@michaelstaib michaelstaib merged commit cb9a542 into main Jul 8, 2026
142 of 144 checks passed
@michaelstaib michaelstaib deleted the mst/perf-080726 branch July 8, 2026 21:32
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