From 240f07d41d9514aea410efcd6f66e2cf8ba3bd1f Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 11 Dec 2024 17:42:33 -0600 Subject: [PATCH] remove SigVerifier::process_excess_packet,process_passed_sigverify_packet --- core/src/sigverify_stage.rs | 9 ++------- perf/benches/shrink.rs | 2 +- perf/src/sigverify.rs | 28 +++++++--------------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/core/src/sigverify_stage.rs b/core/src/sigverify_stage.rs index a8a73a84648847..a59df5ae36fea3 100644 --- a/core/src/sigverify_stage.rs +++ b/core/src/sigverify_stage.rs @@ -13,7 +13,7 @@ use { solana_measure::measure::Measure, solana_perf::{ deduper::{self, Deduper}, - packet::{Packet, PacketBatch}, + packet::PacketBatch, sigverify::{ count_discarded_packets, count_packets_in_batches, count_valid_packets, shrink_batches, }, @@ -57,7 +57,6 @@ pub struct SigVerifyStage { pub trait SigVerifier { type SendType: std::fmt::Debug; fn verify_batches(&self, batches: Vec, valid_packets: usize) -> Vec; - fn process_passed_sigverify_packet(&mut self, _packet: &Packet) {} fn send_packets(&mut self, packet_batches: Vec) -> Result<(), Self::SendType>; } @@ -328,11 +327,7 @@ impl SigVerifyStage { let mut verify_time = Measure::start("sigverify_batch_time"); let mut batches = verifier.verify_batches(batches, num_packets_to_verify); - let num_valid_packets = count_valid_packets( - &batches, - #[inline(always)] - |valid_packet| verifier.process_passed_sigverify_packet(valid_packet), - ); + let num_valid_packets = count_valid_packets(&batches); verify_time.stop(); // Post-shrink packet batches if many packets are discarded from sigverify diff --git a/perf/benches/shrink.rs b/perf/benches/shrink.rs index 4459f5f9a6b0c3..92f377548cf2d5 100644 --- a/perf/benches/shrink.rs +++ b/perf/benches/shrink.rs @@ -79,6 +79,6 @@ fn bench_shrink_count_packets(bencher: &mut Bencher) { }); bencher.iter(|| { - let _ = sigverify::count_valid_packets(&batches, |_| ()); + let _ = sigverify::count_valid_packets(&batches); }); } diff --git a/perf/src/sigverify.rs b/perf/src/sigverify.rs index 5f90001ddb7344..e07da9bcecf732 100644 --- a/perf/src/sigverify.rs +++ b/perf/src/sigverify.rs @@ -146,24 +146,10 @@ pub fn count_packets_in_batches(batches: &[PacketBatch]) -> usize { batches.iter().map(|batch| batch.len()).sum() } -pub fn count_valid_packets( - batches: &[PacketBatch], - mut process_valid_packet: impl FnMut(&Packet), -) -> usize { +pub fn count_valid_packets(batches: &[PacketBatch]) -> usize { batches .iter() - .map(|batch| { - batch - .iter() - .filter(|p| { - let should_keep = !p.meta().discard(); - if should_keep { - process_valid_packet(p); - } - should_keep - }) - .count() - }) + .map(|batch| batch.iter().filter(|p| !p.meta().discard()).count()) .sum() } @@ -1462,7 +1448,7 @@ mod tests { }); start.sort_by(|a, b| a.data(..).cmp(&b.data(..))); - let packet_count = count_valid_packets(&batches, |_| ()); + let packet_count = count_valid_packets(&batches); shrink_batches(&mut batches); //make sure all the non discarded packets are the same @@ -1473,7 +1459,7 @@ mod tests { .for_each(|p| end.push(p.clone())) }); end.sort_by(|a, b| a.data(..).cmp(&b.data(..))); - let packet_count2 = count_valid_packets(&batches, |_| ()); + let packet_count2 = count_valid_packets(&batches); assert_eq!(packet_count, packet_count2); assert_eq!(start, end); } @@ -1637,13 +1623,13 @@ mod tests { PACKETS_PER_BATCH, ); assert_eq!(batches.len(), BATCH_COUNT); - assert_eq!(count_valid_packets(&batches, |_| ()), PACKET_COUNT); + assert_eq!(count_valid_packets(&batches), PACKET_COUNT); batches.iter_mut().enumerate().for_each(|(i, b)| { b.iter_mut() .enumerate() .for_each(|(j, p)| p.meta_mut().set_discard(set_discard(i, j))) }); - assert_eq!(count_valid_packets(&batches, |_| ()), *expect_valid_packets); + assert_eq!(count_valid_packets(&batches), *expect_valid_packets); debug!("show valid packets for case {}", i); batches.iter_mut().enumerate().for_each(|(i, b)| { b.iter_mut().enumerate().for_each(|(j, p)| { @@ -1657,7 +1643,7 @@ mod tests { let shrunken_batch_count = batches.len(); debug!("shrunk batch test {} count: {}", i, shrunken_batch_count); assert_eq!(shrunken_batch_count, *expect_batch_count); - assert_eq!(count_valid_packets(&batches, |_| ()), *expect_valid_packets); + assert_eq!(count_valid_packets(&batches), *expect_valid_packets); } } }