Skip to content

[Fusion] Fix redundant copying of typed input lists - #10605

Draft
tobias-tengler wants to merge 3 commits into
mainfrom
tte/typed-input-list-coercion
Draft

tobias-tengler wants to merge 3 commits into
mainfrom
tte/typed-input-list-coercion

Conversation

@tobias-tengler

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

Copy link
Copy Markdown
Member

Ordinary successful warm mutations with typed list variables validate items into temporary storage, then copy them into the final owned array. This repeats a copy and pooled-buffer bookkeeping even though the JSON array length is already known.

This PR fills the final owned array directly while preserving item validation order, first-error paths, nested lists and scalar-to-list fallback. Empty lists retain shared empty storage, and request values remain independently owned.

Method Version Mean Ratio Allocated Alloc Ratio
Coerce one product ID (changing value) main 280.62 ns 1.00 528 B 1.00
Coerce one product ID (changing value) PR 241.96 ns 0.86 528 B 1.00
Coerce three product IDs (changing values) main 362.74 ns 1.00 672 B 1.00
Coerce three product IDs (changing values) PR 320.85 ns 0.88 672 B 1.00
Coerce five product IDs (catalog control) main 448.75 ns 1.00 816 B 1.00
Coerce five product IDs (catalog control) PR 401.04 ns 0.89 816 B 1.00
Coerce changing one/three product IDs main 321.15 ns 1.00 600 B 1.00
Coerce changing one/three product IDs PR 286.42 ns 0.89 600 B 1.00
Coerce empty list control main 198.80 ns 1.00 368 B 1.00
Coerce empty list control PR 180.29 ns 0.91 368 B 1.00
Coerce Int variable control main 210.43 ns 1.00 416 B 1.00
Coerce Int variable control PR 196.28 ns 0.93 416 B 1.00
Reject invalid second item control main 720.23 ns 1.00 2520 B 1.00
Reject invalid second item control PR 667.31 ns 0.93 2568 B 1.02
Use missing variable default control main 136.04 ns 1.00 336 B 1.00
Use missing variable default control PR 136.38 ns 1.00 336 B 1.00
Coerce scalar to list control main 250.36 ns 1.00 528 B 1.00
Coerce scalar to list control PR 236.91 ns 0.95 528 B 1.00

The complete production variable-coercion helper, including UTF8 output consumption and owned-output escape, improved 10.8–13.8% for the ordinary one/three-item cases, meeting the localized 5% gate; five items are a derived catalog control. Means include all 360 observations and 36 native MemoryDiagnoser rows from two independent launches per arm (BDN 0.15.8, Release .NET 10.0.12, ARM64, server GC, two CPUs). main is 284f0b5f44cf, measured source c66f6ae4f182, and published source 9f0dee621aeb uses equivalent declaration syntax with identical .NET 10 method bodies; Debug .NET 11 style validation and 34 Release tests passed. Successful allocation is unchanged. The error control adds 48 B (1.9%) for its abandoned three-slot array. Scalar/singleton controls also run faster; no control adjustment or observations were removed. This measures CPU-bound helper elapsed time, not whole-gateway performance.

@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (22/22)

File Covered Changed Patch %
…/src/Fusion.Execution/Execution/JsonVariableCoercion.cs 22 22 100.0% 🟢

Project coverage: 59.0% (311546/527834 lines)

This branch has not been deployed

No deployments
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