Skip to content

[Fusion] Reuse the value completion of a pooled result store - #10616

Closed
tobias-tengler wants to merge 3 commits into
mainfrom
tte/fusion-reuse-pooled-value-completion
Closed

tobias-tengler wants to merge 3 commits into
mainfrom
tte/fusion-reuse-pooled-value-completion

Conversation

@tobias-tengler

@tobias-tengler tobias-tengler commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Stacked on #10613 (keep duplicate lookup targets as result cursors), which is stacked on #10612. The base branch is tte/fusion-duplicate-lookup-target-cursors, so the diff shows only this change.

A pooled FetchResultStore creates a new ValueCompletion every time it is initialized for a request, even though the schema, error handler and error handling mode it is created with are usually the same as for the previous request.

This PR keeps the ValueCompletion of a pooled store across requests and creates a new one only when the schema, error handler or error handling mode differ.

Method Version Mean Error Ratio Allocated Alloc Ratio
Initialize and clean #10613 15.40 µs 0.353 µs 1.00 132,195 B 1.000
Initialize and clean PR 15.43 µs 0.421 µs 1.00 132,121 B 0.999

One store lifecycle of a request (initialize and clean). The store allocates 74 B less per request, with time unchanged within the error interval. A small, reliable allocation win on a per-request path.

When one lookup result is merged into a primary target and several additional
targets, the primary target is completed from the source data and, when every
completed value is a non-null, non-enum leaf of an object with the same
selection set, the completed rows are copied into each additional target
instead of completing the same source data again. Targets that do not qualify,
merges with errors and pocketed errors keep the existing completion.
Additional targets of a lookup variable set are kept as cursors into the
result document instead of building a path per target. The merge uses the
cursors directly while no value that references an object or a list was
replaced since the targets were collected, and resolves the target from the
root by its path otherwise. The paths of a CompactPathSegment are created on
first access, so error attribution, telemetry and custom clients keep working.
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

92.7% of changed lines covered (293/316)

File Covered Changed Patch %
…/src/Fusion.Execution/Execution/Results/FetchResultStore.cs 127 148 85.8% 🟡
…/Fusion/src/Fusion.Execution/Text/Json/CompactPathSegment.cs 13 15 86.7% 🟡
…/Execution/Results/AdditionalPathAccumulator.cs 88 88 100.0% 🟢
…/Execution/Results/FetchResultStore.Pooling.cs 10 10 100.0% 🟢
…/Execution/Results/FetchResultStore.RepresentationValue.cs 9 9 100.0% 🟢
…/src/Fusion.Execution/Execution/Results/TargetCursorPaths.cs 17 17 100.0% 🟢
…/src/Fusion.Execution/Execution/Results/ValueCompletion.cs 3 3 100.0% 🟢
…/src/Fusion.Execution/Text/Json/CompositeObjectContext.cs 1 1 100.0% 🟢
…/Fusion.Execution/Text/Json/CompositeResultDocument.MetaDb.cs 8 8 100.0% 🟢
…/src/Fusion.Execution/Text/Json/CompositeResultDocument.cs 17 17 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "468a282cf1f87fddbb8957d07efb1250077caa4a",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs", "ranges": [[729, 731], [733, 733], [751, 752], [759, 760], [773, 773], [789, 790], [805, 806], [835, 836], [845, 846], [888, 889], [924, 925]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompactPathSegment.cs", "ranges": [[85, 85], [90, 90]] }
  ]
}

Project coverage: 59.0% (311709/528004 lines)

@tobias-tengler
tobias-tengler changed the base branch from main to tte/fusion-duplicate-lookup-target-cursors October 19, 2026 06:44
Base automatically changed from tte/fusion-duplicate-lookup-target-cursors to main October 21, 2026 05:51
@tobias-tengler
tobias-tengler deleted the tte/fusion-reuse-pooled-value-completion branch October 21, 2026 15:51
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.

1 participant