Skip to content

Service Bus send preparation allocates strings for the default UTF-8 envelope #295

Closed
1 of 1 issue completed

Description

@thomhurst

Service Bus send preparation converts nonempty UTF-8 CloudEvents values to strings because Azure.Messaging.ServiceBus 7.21.0 requires strings to preserve AMQP text values. Approved D52 (76402e0 on main) now classifies native-signature-required objects as native-client cost when a raw-client comparison allocates at least as much. The former absolute-zero release hold no longer applies; reconcile the send documentation and allocation checks with that policy.

Remaining work

  • Reuse the allocation/lifetime tests and DefaultJson ISender/native comparison shipped in Measure Service Bus UTF-8 allocations and default JSON sends #300 (34f00f7), closing Measure Service Bus UTF-8 send allocations and default-JSON sender comparison #297. Do not rebuild them.
  • Inspect ServiceBusSendAllocationTests and ServiceBusHeaderBenchmarks against D52. Pin the native-required conversions with changing IDs/timestamps and creation context; compare the same preparation work with the raw SDK and keep all additional Relayer pipeline allocations at zero.
  • Correct website/docs/transports/service-bus.md, which still calls these required conversions Relayer-owned budget violations and says matching the native baseline cannot satisfy the budget. Name the required objects and state the measured comparison honestly; the 5% throughput budget is unchanged.
  • Preserve native text wire types, stored creation context, bounded retention and terminal borrowed-memory detachment. Retain the existing DefaultJson acknowledged comparison.

Upstream follow-up

Azure/azure-sdk-for-net#64450 remains open for borrowed UTF-8 text support. Remove the conversions when a supported native equivalent ships. It is an optimization follow-up, not a prerequisite under D52. Do not replace native AMQP encoding or cache unbounded changing IDs.

Acceptance: focused allocation/lifetime tests pass; the native comparison covers equivalent work and is documented without claiming unmeasured throughput compliance; the site builds. No new performance trade-off or budget exception is authorized.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    bug
    P2
    in-progress
    on Nov 2, 2026
  2. added
    on-hold
    and removed
    in-progress
    on Nov 2, 2026
  3. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Native-first investigation confirms an external API gap: Azure.Messaging.ServiceBus 7.21.0 delegates to Azure.Core.Amqp 1.3.1, whose AMQP string application-property input is System.String. The public content-type property is also System.String. A credential-free round-trip probe confirms byte[]/ArraySegment produce binary values, and ReadOnlyMemory throws SerializationException. These are not wire-compatible UTF-8 text alternatives.

    Filed Azure/azure-sdk-for-net#64450 with pinned source links and a minimal reproduction. Changing IDs and timestamps defeat finite string caching. Unbounded caching, unsafe mutation of strings, or a parallel AMQP encoder would violate the existing lifetime/performance/native-reuse rules.

    The zero-allocation requirement is on hold until a released native API accepts reusable UTF-8 text as AMQP string (or upstream identifies an existing supported equivalent). This does not waive D18. Independent allocation regressions and the missing real default-JSON ISender comparison are split into native child #297 and are being implemented now. Existing ownership, creation-context and wire semantics remain required.

    Local measurement work is now in draft PR #300, closing child #297. It adds six allocation/lifetime cases and the default-JSON ISender/native comparison. The zero-allocation implementation remains blocked by the native text API described above.

  4. removed
    on-hold
    on Nov 10, 2026
  5. thomhurst commented on Nov 10, 2026

    @thomhurst
    OwnerAuthor

    Approved D52 is now on main (76402e0), so removed the obsolete absolute-zero hold and rewrote the issue around the remaining send docs/allocation-policy reconciliation. #300 already delivered #297’s tests and benchmarks. Azure/azure-sdk-for-net#64450 remains an upstream optimization request; D52 still requires the equivalent raw-client comparison and zero additional pipeline allocations.

  6. added
    in-progress
    on Nov 10, 2026
  7. thomhurst commented on Nov 10, 2026

    @thomhurst
    OwnerAuthor

    Rechecked native child #297 (closed) and current origin/main. D52 documentation largely shipped, but the existing allocation test still discarded converted strings and stated the old absolute-zero restriction. Draft #373 completes the remaining acceptance work: equivalent warmed native SDK preparation, exact allocation equality, stored creation-context benchmark cases and matching site text.

    Six focused allocation/lifetime cases pass: adapter/raw preparation is 312/368 B/send without tracing and 504/560 B/send with tracing (string/UTF-8 content type), with 0 additional B in all cases on .NET 10.0.14 arm64. The site builds, benchmark project compiles, and all eight Dry/in-process header cases execute. Existing DefaultJson acknowledged comparison and lifetime behavior are preserved. No throughput compliance is claimed. Commit: 69524ab.

    The issue closes when #373 merges; upstream Azure/azure-sdk-for-net#64450 remains an optimization follow-up under D52.

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