From 0da01270efe72d5d4c6652199d223a373c6f839e Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 6 Jul 2023 18:25:20 +0000 Subject: [PATCH] removes redundant recycler clones (#32401) --- core/src/repair/serve_repair.rs | 2 +- entry/src/entry.rs | 2 +- gossip/src/cluster_info.rs | 12 ++++++------ perf/src/packet.rs | 13 ++++++------- streamer/src/streamer.rs | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/src/repair/serve_repair.rs b/core/src/repair/serve_repair.rs index bacf658663aae8..735804a91046ac 100644 --- a/core/src/repair/serve_repair.rs +++ b/core/src/repair/serve_repair.rs @@ -1298,7 +1298,7 @@ impl ServeRepair { nonce: Nonce, ) -> Option { let mut res = - PacketBatch::new_unpinned_with_recycler(recycler.clone(), max_responses, "run_orphan"); + PacketBatch::new_unpinned_with_recycler(recycler, max_responses, "run_orphan"); // Try to find the next "n" parent slots of the input slot let packets = std::iter::successors(blockstore.meta(slot).ok()?, |meta| { blockstore.meta(meta.parent_slot?).ok()? diff --git a/entry/src/entry.rs b/entry/src/entry.rs index 7456ad74925598..351c74b9b3ce29 100644 --- a/entry/src/entry.rs +++ b/entry/src/entry.rs @@ -539,7 +539,7 @@ fn start_verify_transactions_gpu( .map(|slice| { let vec_size = slice.len(); let mut packet_batch = PacketBatch::new_with_recycler( - verify_recyclers.packet_recycler.clone(), + &verify_recyclers.packet_recycler, vec_size, "entry-sig-verify", ); diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 7a680cd96b4d47..abff856a15a901 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -502,7 +502,7 @@ impl ClusterInfo { .packets_sent_gossip_requests_count .add_relaxed(pings.len() as u64); let packet_batch = PacketBatch::new_unpinned_with_recycler_data_and_dests( - recycler.clone(), + recycler, "refresh_push_active_set", &pings, ); @@ -1653,7 +1653,7 @@ impl ClusterInfo { ); if !reqs.is_empty() { let packet_batch = PacketBatch::new_unpinned_with_recycler_data_and_dests( - recycler.clone(), + recycler, "run_gossip", &reqs, ); @@ -2034,7 +2034,7 @@ impl ClusterInfo { let output_size_limit = self.update_data_budget(stakes.len()) / PULL_RESPONSE_MIN_SERIALIZED_SIZE; let mut packet_batch = - PacketBatch::new_unpinned_with_recycler(recycler.clone(), 64, "handle_pull_requests"); + PacketBatch::new_unpinned_with_recycler(recycler, 64, "handle_pull_requests"); let (caller_and_filters, addrs): (Vec<_>, Vec<_>) = { let mut rng = rand::thread_rng(); let check_pull_request = @@ -2276,7 +2276,7 @@ impl ClusterInfo { None } else { let packet_batch = PacketBatch::new_unpinned_with_recycler_data_and_dests( - recycler.clone(), + recycler, "handle_ping_messages", &pongs_and_dests, ); @@ -2372,7 +2372,7 @@ impl ClusterInfo { return; } let mut packet_batch = PacketBatch::new_unpinned_with_recycler_data_and_dests( - recycler.clone(), + recycler, "handle_batch_push_messages", &prune_messages, ); @@ -3087,7 +3087,7 @@ pub fn push_messages_to_peer( .map(move |payload| (peer_gossip, Protocol::PushMessage(self_id, payload))) .collect(); let packet_batch = PacketBatch::new_unpinned_with_recycler_data_and_dests( - PacketBatchRecycler::default(), + &PacketBatchRecycler::default(), "push_messages_to_peer", &reqs, ); diff --git a/perf/src/packet.rs b/perf/src/packet.rs index 0fc961567717f5..b030f04dae8ce6 100644 --- a/perf/src/packet.rs +++ b/perf/src/packet.rs @@ -43,7 +43,7 @@ impl PacketBatch { } pub fn new_unpinned_with_recycler( - recycler: PacketBatchRecycler, + recycler: &PacketBatchRecycler, capacity: usize, name: &'static str, ) -> Self { @@ -53,7 +53,7 @@ impl PacketBatch { } pub fn new_with_recycler( - recycler: PacketBatchRecycler, + recycler: &PacketBatchRecycler, capacity: usize, name: &'static str, ) -> Self { @@ -67,13 +67,13 @@ impl PacketBatch { name: &'static str, mut packets: Vec, ) -> Self { - let mut batch = Self::new_with_recycler(recycler.clone(), packets.len(), name); + let mut batch = Self::new_with_recycler(recycler, packets.len(), name); batch.packets.append(&mut packets); batch } pub fn new_unpinned_with_recycler_data_and_dests( - recycler: PacketBatchRecycler, + recycler: &PacketBatchRecycler, name: &'static str, dests_and_data: &[(SocketAddr, T)], ) -> Self { @@ -102,7 +102,7 @@ impl PacketBatch { name: &'static str, mut packets: Vec, ) -> Self { - let mut batch = Self::new_unpinned_with_recycler(recycler.clone(), packets.len(), name); + let mut batch = Self::new_unpinned_with_recycler(recycler, packets.len(), name); batch.packets.append(&mut packets); batch } @@ -278,8 +278,7 @@ mod tests { fn test_to_packets_pinning() { let recycler = PacketBatchRecycler::default(); for i in 0..2 { - let _first_packets = - PacketBatch::new_with_recycler(recycler.clone(), i + 1, "first one"); + let _first_packets = PacketBatch::new_with_recycler(&recycler, i + 1, "first one"); } } } diff --git a/streamer/src/streamer.rs b/streamer/src/streamer.rs index 35b0099f2b3bb8..1fd7bfc97404cc 100644 --- a/streamer/src/streamer.rs +++ b/streamer/src/streamer.rs @@ -113,7 +113,7 @@ fn recv_loop( ) -> Result<()> { loop { let mut packet_batch = if use_pinned_memory { - PacketBatch::new_with_recycler(recycler.clone(), PACKETS_PER_BATCH, stats.name) + PacketBatch::new_with_recycler(recycler, PACKETS_PER_BATCH, stats.name) } else { PacketBatch::with_capacity(PACKETS_PER_BATCH) };