Skip to content

Add Fusion result-composition hot path micro benchmarks - #10133

Merged
michaelstaib merged 1 commit into
mainfrom
mst/fusion-hotpath-benchmarks
Jul 21, 2026
Merged

Add Fusion result-composition hot path micro benchmarks#10133
michaelstaib merged 1 commit into
mainfrom
mst/fusion-hotpath-benchmarks

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

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

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

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 __typename bytes 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
@michaelstaib
michaelstaib merged commit 9a846d7 into main Jul 21, 2026
148 checks passed
@michaelstaib
michaelstaib deleted the mst/fusion-hotpath-benchmarks branch July 21, 2026 22:08
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