Add Fusion result-composition hot path micro benchmarks - #10133
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a set of BenchmarkDotNet microbenchmarks focused on Fusion execution “result composition” hot paths, intended to quantify candidate micro-optimizations (string transcoding avoidance, selection-set lookup flattening, MetaDb row reads, row reuse, templated object row writes, and abstract type resolution memoization).
Changes:
- Added benchmark for hoisting UTF-8 transcoding of source-path segments during per-result JSON document walks.
- Added benchmarks for selection set child lookup, MetaDb row reads, enum/scalar list element completion row reuse, and templated object row materialization.
- Added benchmark for memoizing abstract type resolution based on
__typenamebytes to avoid allocations/lookups on homogeneous lists.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/SourcePathTranscodeHoistBenchmark.cs | Benchmarks per-result source-path walking with per-segment string transcode vs hoisted UTF-8 segment bytes. |
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/ResultSelectionSetLookupBenchmark.cs | Benchmarks current ResultSelectionSet.TryGetChild vs a benchmark-local flattened sealed implementation. |
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/MetaDbGetBenchmark.cs | Benchmarks MetaDb row reads via product API vs local span-read copy vs GetArrayDataReference + Unsafe.ReadUnaligned. |
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/EnumScalarRowReuseBenchmark.cs | Benchmarks repeated row decode vs single-decode row reuse for enum/scalar list element completion. |
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/CompositeObjectCreateTemplateBenchmark.cs | Benchmarks per-row append loop vs template block-copy + parent stamping for composite object row creation. |
| src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/AbstractTypeResolutionMemoBenchmark.cs | Benchmarks baseline abstract type resolution vs 1-entry and 2-entry MRU memoization using raw UTF-8 type names. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+136
to
+140
| [GlobalCleanup] | ||
| public void Cleanup() | ||
| { | ||
| _arena.Dispose(); | ||
| } |
Comment on lines
+58
to
+65
| #pragma warning disable IDE0370 // Remove unnecessary suppression | ||
| private MemoryArena _arena = null!; | ||
| private SourceResultDocument _document = null!; | ||
| private SourceResultDocument.MetaDb _metaDb; | ||
| private MemorySegment[] _chunks = null!; | ||
| private SourceResultDocument.Cursor[] _cursors = null!; | ||
| private SourceResultDocument.DbRow[] _expectedRows = null!; | ||
| #pragma warning restore IDE0370 // Remove unnecessary suppression |
Comment on lines
+59
to
+65
| #pragma warning disable IDE0370 // Remove unnecessary suppression | ||
| private MemoryArena _arena = null!; | ||
| private SourceResultDocument _document = null!; | ||
| private SourceResultElement[] _enumElements = null!; | ||
| private SourceResultElement[] _numberElements = null!; | ||
| private FusionEnumValueCollection _enumValues = null!; | ||
| #pragma warning restore IDE0370 // Remove unnecessary suppression |
Comment on lines
+81
to
+88
| #pragma warning disable IDE0370 // Remove unnecessary suppression | ||
| private FusionOperation _operation = null!; | ||
| private SelectionSet _selectionSet = null!; | ||
| private byte[] _baselineChunk = null!; | ||
| private byte[] _templateChunk = null!; | ||
| private byte[] _template = null!; | ||
| private int[] _parents = null!; | ||
| #pragma warning restore IDE0370 // Remove unnecessary suppression |
This was referenced Aug 9, 2026
Merged
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.