Skip to content

Avoid redundant tuple extraction allocations during data generation #7552

Closed

Description

@thomhurst

Summary

Generic tuple row binding can allocate an element array merely to check whether a singleton reference-tuple target contains null. Avoiding that extraction would reduce allocations during data generation. The relevant helper is introduced by PR #7548 (closing #7514), so this follow-up depends on #7514.

Reproduction

Inspect DataSourceHelpers.ShouldFlattenErasedTuple at PR #7548 head 6843efecf3abc42061b0d81f84a1bbc463783de2. For System.Tuple singleton targets, the null check calls UnwrapTupleAot(tuple), which copies elements into a new array even when the row is non-null and will be flattened. RequiresFlattenedTupleBinding also extracts elements for mutable shapes, but the latest control flow does not call both helpers' extraction paths for the same reference-tuple-target decision. The earlier duplicate-extraction description no longer matches that head.

At main 4891fce71adee5d0d66e19c9fc20a367b9cca1e9, ShouldFlattenErasedTuple has not landed yet.

Acceptance criteria

  • Measure allocation counts before and after for singleton reference-tuple targets with null and non-null elements, and mutable-element rows.
  • Avoid allocating a temporary element array solely for the singleton null decision, or reuse extraction needed by subsequent binding. Consider caching target classification only if measurements justify it.
  • Preserve null rows, nested tuple containers, conversions, and mutable boxed-element behavior in generated and reflection discovery.
  • Retain Native AOT compatibility and run the focused tuple regressions in both modes.

Please reduce the avoidable tuple extraction allocation in this binding decision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low: cleanup, minor enhancement, or rare edge caseenhancementNew feature or requestin-progressWork is in progressperformancePerformance optimization

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions