From a53a87657c945efd0fc2c6d7edcc2213cff44495 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 6 Dec 2024 01:18:52 +1100 Subject: [PATCH] ed25519_verify_cpu: remove allocation in hot path (#3941) The old code was a remnant from a time when we tried to "balance" the amount of work across threads by re-batching and therefore allocating. This is a hot path. Allocations are bad. Let work stealing work its magic. --- perf/src/sigverify.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/perf/src/sigverify.rs b/perf/src/sigverify.rs index 90cefe630e31ae..eff58d2cdf7b2d 100644 --- a/perf/src/sigverify.rs +++ b/perf/src/sigverify.rs @@ -515,18 +515,11 @@ pub fn shrink_batches(batches: &mut Vec) { pub fn ed25519_verify_cpu(batches: &mut [PacketBatch], reject_non_vote: bool, packet_count: usize) { debug!("CPU ECDSA for {}", packet_count); PAR_THREAD_POOL.install(|| { - batches - .par_iter_mut() - .flatten() - .collect::>() - .par_chunks_mut(VERIFY_PACKET_CHUNK_SIZE) - .for_each(|packets| { - for packet in packets.iter_mut() { - if !packet.meta().discard() && !verify_packet(packet, reject_non_vote) { - packet.meta_mut().set_discard(true); - } - } - }); + batches.par_iter_mut().flatten().for_each(|packet| { + if !packet.meta().discard() && !verify_packet(packet, reject_non_vote) { + packet.meta_mut().set_discard(true); + } + }); }); }