Skip to content

refactor: remove unnecessary Arc::clone in repair_shred_from_peer#10573

Merged
steviez merged 1 commit intoanza-xyz:masterfrom
MozirDmitriy:unnecessary-arc-clone
Feb 17, 2026
Merged

refactor: remove unnecessary Arc::clone in repair_shred_from_peer#10573
steviez merged 1 commit intoanza-xyz:masterfrom
MozirDmitriy:unnecessary-arc-clone

Conversation

@MozirDmitriy
Copy link
Copy Markdown

Problem

[request_repair_for_shred_from_peer]

pub fn request_repair_for_shred_from_peer(
cluster_info: Arc<ClusterInfo>,
cluster_slots: Arc<ClusterSlots>,
pubkey: Option<Pubkey>,
slot: u64,
shred_index: u64,
repair_socket: &UdpSocket,
outstanding_repair_requests: Arc<RwLock<OutstandingShredRepairs>>,
) {
let mut repair_peers = vec![];
// Check validity of passed in peer.
if let Some(pubkey) = pubkey {
let peer_repair_addr =
cluster_info.lookup_contact_info(&pubkey, |node| node.serve_repair(Protocol::UDP));
if let Some(Some(peer_repair_addr)) = peer_repair_addr {
trace!("Repair peer {pubkey} has valid repair socket: {peer_repair_addr:?}");
repair_peers.push((pubkey, peer_repair_addr));
}
};
// Select weighted sample of valid peers if no valid peer was passed in.
if repair_peers.is_empty() {
debug!(
"No pubkey was provided or no valid repair socket was found. Sampling a set of \
repair peers instead."
);
repair_peers = Self::get_repair_peers(cluster_info.clone(), cluster_slots, slot);
}
// Send repair request to each peer.
for (pubkey, peer_repair_addr) in repair_peers {
Self::request_repair_for_shred_from_address(
cluster_info.clone(),
pubkey,
peer_repair_addr,
slot,
shred_index,
repair_socket,
outstanding_repair_requests.clone(),
);
}
}
takes repair_socket: &UdpSocket, but the call site was doing &post_init.repair_socket.clone() - cloning the Arc<UdpSocket> just to immediately borrow it. This is redundant because &Arc<UdpSocket> auto-derefs to &UdpSocket via the Deref trait.

Summary of Changes

Remove the unnecessary .clone() to avoid a needless atomic refcount increment/decrement.

@mergify mergify Bot requested a review from a team February 17, 2026 20:45
@steviez steviez added the CI Pull Request is ready to enter CI label Feb 17, 2026
@anza-team anza-team removed the CI Pull Request is ready to enter CI label Feb 17, 2026
Copy link
Copy Markdown

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Thanks and FWIW - someone is looking to add a lint to catch these with (#10121)

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.0%. Comparing base (bf9c84d) to head (a2ee20c).
⚠️ Report is 35 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10573   +/-   ##
=======================================
  Coverage    83.0%    83.0%           
=======================================
  Files         843      843           
  Lines      315803   315803           
=======================================
+ Hits       262275   262301   +26     
+ Misses      53528    53502   -26     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@steviez steviez added this pull request to the merge queue Feb 17, 2026
Merged via the queue into anza-xyz:master with commit 9c4b2fd Feb 17, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants