Resolve Fusion abstract types via allocation-free ASCII byte lookup - #10150
Conversation
There was a problem hiding this comment.
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
FusionTypeDefinitionCollectionoverloads to resolve types from raw UTF-8 bytes (withFrozenDictionaryalternate lookup on newer runtimes). - Update execution-time abstract type resolution (
ValueCompletion) to useAssertUtf8String()+ 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.
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>
|
|
Patch coverage75.0% of changed lines covered (78/104)
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) |
No description provided.