Skip to content

[Fusion] Reduce per request allocations#9512

Merged
michaelstaib merged 6 commits intomainfrom
mst/fusion-perf-080426-1
Apr 8, 2026
Merged

[Fusion] Reduce per request allocations#9512
michaelstaib merged 6 commits intomainfrom
mst/fusion-perf-080426-1

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 08:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 reducing per-request allocations in Fusion execution by replacing temporary collections with pooled buffers and tighter data structures.

Changes:

  • Replace Path.ToList()-based segment materialization with ArrayPool-backed buffers and a new Path.CopyTo(Span<object>) API.
  • Pool VariableValues[] allocations in FetchResultStore and copy out the final immutable result.
  • Reduce runtime overhead in execution state tracking (bitset instead of HashSet<int>) and avoid repeated schema name computation during subscription event processing.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/PathUtilities.cs Uses pooled object[] buffers to compare path segments without allocating lists.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs Uses pooled buffers for path traversal and variable value set construction/finalization.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanExecutor.cs Caches schemaName once for subscription event diagnostics.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.Pooling.cs Ensures pooled execution state resources are released on context destruction.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.cs Reduces allocations when materializing skipped definitions and forwarded variable field nodes.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ExecutionState.cs Replaces skipped/failed tracking with a pooled bitset and pools internal arrays.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/SourceSchemaErrors.cs Switches to Path.CopyTo and reuses a cached shared ArrayPool<object>.
src/HotChocolate/Core/src/Execution.Abstractions/Path.cs Renames span-based path materialization to CopyTo(Span<object>) and updates docs.

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

Comment thread src/HotChocolate/Core/src/Execution.Abstractions/Path.cs
Comment thread src/HotChocolate/Core/src/Execution.Abstractions/Path.cs
@michaelstaib michaelstaib added the Area: Performance Issue is related to performance label Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (d68df74) to head (2de82db).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9512   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Performance Issue is related to performance 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants