Skip to content

perf(broadcast): transfer reclaimed head message directly on receive - #390

Merged
tisonkun merged 6 commits into
apache:mainfrom
tisonkun:codex/broadcast-recv-reclaim
Nov 1, 2026
Merged

tisonkun merged 6 commits into
apache:mainfrom
tisonkun:codex/broadcast-recv-reclaim

Conversation

@tisonkun

Copy link
Copy Markdown
Member

Summary

  • Transfer the head slot's Arc<T> directly to the caller when Backlog::receive vacates the front of the buffer, instead of cloning slot.msg under the channel lock and routing the original Arc<T> through Reclaimed<T> only to drop it in share_msg / take_msg.
  • Narrow Received<T> to { msg: Arc<T>, reclaimed: bool }, keeping Reclaimed<T> exclusively for Backlog::remove_receiver when a dropped subscription vacates an unread prefix.
  • Guard BoundedSender's release_reclaimed against freed == 0 and only invoke it when a receive actually vacates the head slot, avoiding an unconditional Ordering::Acquire load of blocked_senders on non-reclaiming receives.
  • Consolidate BoundedReceiver<T> and UnboundedReceiver<T> methods into a single impl<T> block per receiver using method-level where T: Clone bounds on recv_cloned and try_recv_cloned.
  • Update broadcast benchmarks to exercise the default shared recv / try_recv path in ecosystem adapters and compare shared vs. cloned String fan-out in primitive benchmarks, and drop the redundant Clone implementation on PanicOnDrop in integration tests.

@tisonkun
tisonkun requested a review from orthur2 October 31, 2026 10:55

@orthur2 orthur2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The try_receive doc still describes the old (Arc<T>, Reclaimed<T>) return.

@tisonkun

tisonkun commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

Resolved in d8facec.

Merging ...

@tisonkun
tisonkun merged commit 11db327 into apache:main Nov 1, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/broadcast-recv-reclaim branch November 1, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants