Skip to content

Retain SendTracing continuation storage across completion threads #304

Closed

Description

@thomhurst

Profiling the outgoing RabbitMQ adapter during #298 exposed recurring continuation allocations in the shared SendTracing wrapper, beyond its already-retained header/span state pool.

At b13bf72, warm the outgoing native comparison, then invoke its asynchronous Relayer method synchronously from a stable calling thread (the same call pattern BenchmarkDotNet uses). A 10,000-send gc-verbose trace records repeated StateMachineBox<VoidTaskResult, Relayer.SendTracing.<SendCoreAsync>d__15> allocations. The runtime's PoolingAsyncValueTaskMethodBuilder cache returns boxes on completion threads and does not retain the workload's full high-water mark for all caller patterns. This is the same class of problem previously attributed in #203, in a different component. It is not JSON, native-client, DI or benchmark-wrapper storage.

Reproduction source, loaded binaries and before/after traces are retained with PR #298. Original trace: C:/git/Relayer-evidence/issue-273/sync.nettrace; sampled allocation summary: sync-allocations.txt. Repeated samples name both RabbitMqNativeTransport.SendCoreAsync and SendTracing.SendCoreAsync. #298 replaces RabbitMQ continuation storage with retained IValueTaskSource operations and bypasses SendTracing's asynchronous wrapper only when there are no listeners; send metrics remain recorded. It does not change the shared wrapper used by the other transports.

Acceptance:

  • Retain an allocation regression that suspends native sends and completes on different threads, exercised both by asynchronously awaited callers and a stable synchronous outer caller.
  • Remove recurring shared SendTracing continuation allocation while preserving failure logging, counters, original creation context, outbox links, trace sampling and borrowed storage ownership.
  • Preserve throughput/latency/CPU and Native AOT; use MemoryDiagnoser and allocation stacks, not pooling attributes alone, as evidence.
  • Check the batch tracing wrapper for the same cache-miss pattern. Do not waive the allocation budget or relabel these allocations as native-client work.

Activity

  1. added
    bug
    P2
    on Nov 2, 2026
  2. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Retained an independent evidence copy at C:/git/Relayer-evidence/issue-304/from-pr-298/ so closing #298 or #273 does not delete this issue's evidence. Verified 291 files against the PR archive by SHA-256; inventory hash 4CA0A1E8E42B0BA1CC0E15620542E7C26CFC36F3AAC558E80578C52E1611E0A4. Includes source and loaded binaries as well as raw reports/traces. Normal retention follows this issue's own lifecycle.
    The earlier exploratory capture is superseded by a new matched baseline on b13bf72 and retained-source candidate on 380871a. Both synchronous-caller probes use the same input source. Recurring SendTracing/RabbitMQ pooled-builder samples appear in the baseline; the candidate uses retained transport completion sources and the spanless fast path. Sampled trace weights are not exact per-method byte totals.

  3. added
    in-progress
    on Nov 2, 2026
  4. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Implemented in #310 at 4adcc1a. Both required reviewers cleared this head, and the repository script marked it ready and armed auto-merge. Required CI is now responsible for the merge.

    Validation: 137 tracing tests and 699 core tests pass; Release solution build, win-x64 Native AOT smoke and documentation build pass. The allocation regression fails baseline and passes the head at 0 B. The PR records timing uncertainty and the isolated unclassified probe allocation rather than waiving the budget.

    Verified evidence archive: C:/git/Relayer-evidence/pr-310/4adcc1acbf5f1c67b3c1867fd757fa90fa0c48cf/. The in-progress claim remains while the PR is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugin-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions