Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes Arc::unwrap_or_clone from StandardBroadcastRun::insert #4706

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

behzadnouri
Copy link

Problem

Broadcast stage wraps Vec<Shred> in Arc to reduce allocations and cloning when shreds are concurrently sent to both BroadcastRun::record and BroadcastRun::transmit:
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage/standard_broadcast_run.rs#L224-L226
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage.rs#L344
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage.rs#L321

However, the unnecessary Arc::unwrap_or_clone in StandardBroadcastRun::insert breaks this memory sharing and forces a clone on shreds transmitted:
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage/standard_broadcast_run.rs#L370

Summary of Changes

The commit removes the unnecessary Arc::unwrap_or_clone and instead just skips the iterator of shreds by one when needed.

Broadcast stage wraps Vec<Shred> in Arc<...> to reduce allocations and
cloning when shreds are concurrently sent to both BroadcastRun::record
and BroadcastRun::transmit:
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage/standard_broadcast_run.rs#L224-L226
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage.rs#L344
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage.rs#L321

However, the unnecessary Arc::unwrap_or_clone in
StandardBroadcastRun::insert breaks this memory sharing and forces a
clone on shreds transmitted:
https://github.com/anza-xyz/agave/blob/b59c1aee7/turbine/src/broadcast_stage/standard_broadcast_run.rs#L370

The commit removes the unnecessary Arc::unwrap_or_clone and instead just
skips the iterator of shreds by one when needed.
@behzadnouri behzadnouri force-pushed the rm-broadcast-unwrap-or-clone branch from ac4c9fc to f36cc81 Compare January 30, 2025 15:59
@behzadnouri behzadnouri marked this pull request as draft January 30, 2025 16:00
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.

1 participant