Skip to content

Commit

Permalink
removes redundant recycler clones (solana-labs#32401)
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri authored Jul 6, 2023
1 parent 4674b00 commit 0da0127
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/src/repair/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ impl ServeRepair {
nonce: Nonce,
) -> Option<PacketBatch> {
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()?
Expand Down
2 changes: 1 addition & 1 deletion entry/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
Expand Down
12 changes: 6 additions & 6 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down
13 changes: 6 additions & 7 deletions perf/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PacketBatch {
}

pub fn new_unpinned_with_recycler(
recycler: PacketBatchRecycler,
recycler: &PacketBatchRecycler,
capacity: usize,
name: &'static str,
) -> Self {
Expand All @@ -53,7 +53,7 @@ impl PacketBatch {
}

pub fn new_with_recycler(
recycler: PacketBatchRecycler,
recycler: &PacketBatchRecycler,
capacity: usize,
name: &'static str,
) -> Self {
Expand All @@ -67,13 +67,13 @@ impl PacketBatch {
name: &'static str,
mut packets: Vec<Packet>,
) -> 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<T: Serialize>(
recycler: PacketBatchRecycler,
recycler: &PacketBatchRecycler,
name: &'static str,
dests_and_data: &[(SocketAddr, T)],
) -> Self {
Expand Down Expand Up @@ -102,7 +102,7 @@ impl PacketBatch {
name: &'static str,
mut packets: Vec<Packet>,
) -> 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
}
Expand Down Expand Up @@ -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");
}
}
}
2 changes: 1 addition & 1 deletion streamer/src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down

0 comments on commit 0da0127

Please sign in to comment.