Skip to content

Resolve Fusion abstract types via allocation-free ASCII byte lookup - #10150

Merged
michaelstaib merged 7 commits into
mainfrom
mst/fusion-typename-ascii-lookup
Jul 27, 2026
Merged

Resolve Fusion abstract types via allocation-free ASCII byte lookup#10150
michaelstaib merged 7 commits into
mainfrom
mst/fusion-typename-ascii-lookup

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 26, 2026 21: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 pull request optimizes Fusion runtime type resolution by avoiding string materialization for __typename where possible, introducing UTF-8 span-based type lookup and an MRU memoization path for abstract type resolution.

Changes:

  • Add FusionTypeDefinitionCollection overloads to resolve types from raw UTF-8 bytes (with FrozenDictionary alternate lookup on newer runtimes).
  • Update execution-time abstract type resolution (ValueCompletion) to use AssertUtf8String() + MRU memoization and span-based schema lookup.
  • Adjust/extend tests and add benchmarks to measure span-based type lookup and memoized abstract type resolution.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Text/Json/SourceResultDocumentTests.cs Removes TryGetRawStringValue tests; should now cover AssertUtf8String.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Types/FusionTypeDefinitionCollectionTests.cs Adds tests for the new span-based type lookup APIs.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Results/FetchResultStoreTests.cs Adds regression coverage for abstract type fallback schema lookup when implementer count exceeds the lookup limit.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/UnionTests.cs Updates expectations for escaped __typename handling in unions.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElementSnapshot.cs Adds AssertUtf8String() to snapshot API and removes TryGetRawStringValue.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs Adds AssertUtf8String() to element API and removes TryGetRawStringValue.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultDocument.Text.cs Removes TryGetRawStringValue implementation from document text helpers.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Switches schema type to FusionSchemaDefinition, adds MRU memo, and uses UTF-8 span lookup for abstract type resolution.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.Pooling.cs Updates initialization to use FusionSchemaDefinition.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs Updates stored schema field type to FusionSchemaDefinition.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.Pooling.cs Casts request schema to FusionSchemaDefinition when initializing the result store.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Collections/FusionTypeDefinitionCollection.cs Implements span-based GetType/TryGetType overloads with optimized NET9 alternate lookup.
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/SpanTypeLookupBenchmark.cs Adds benchmark for span-based schema type lookup to validate allocation improvements.
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/AbstractTypeResolutionMemoBenchmark.cs Updates benchmark to reflect AssertUtf8String + span-keyed lookup path.

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

Comment thread src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Outdated
michaelstaib and others added 2 commits July 27, 2026 08:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ michaelstaib
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

75.0% of changed lines covered (78/104)

File Covered Changed Patch %
…/Fusion.Execution/Text/Json/SourceResultElementSnapshot.cs 0 6 0.0% 🔴
…/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs 4 6 66.7% 🔴
…/Collections/FusionTypeDefinitionCollection.cs 44 62 71.0% 🔴
…/Fusion.Execution/Execution/OperationPlanContext.Pooling.cs 1 1 100.0% 🟢
…/src/Fusion.Execution/Execution/Results/FetchResultStore.cs 1 1 100.0% 🟢
…/src/Fusion.Execution/Execution/Results/ValueCompletion.cs 28 28 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "9356dc1e7204338bbe2fee0c87838bb4d6557fbe",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElementSnapshot.cs", "ranges": [[264, 267], [270, 271]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElement.cs", "ranges": [[299, 300]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution.Types/Collections/FusionTypeDefinitionCollection.cs", "ranges": [[17, 17], [180, 183], [196, 199], [209, 211], [248, 250], [269, 271]] }
  ]
}

Project coverage: 53.8% (231911/430722 lines)

@michaelstaib
michaelstaib merged commit 6663318 into main Jul 27, 2026
4 of 5 checks passed
@michaelstaib
michaelstaib deleted the mst/fusion-typename-ascii-lookup branch July 27, 2026 11:12
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.

4 participants