Skip to content

Commit 22f2f6d

Browse files
authored
perf: Resolve Rust 1.88 clippy lints and format strings (#7044)
- Run `cargo clippy --fix --tests` with Rust 1.88.0 set in `rust-toolchain.toml` - Run `cargo fmt` with `format_strings = true` set in `rustfmt.toml`
1 parent fb69c5b commit 22f2f6d

File tree

7 files changed

+30
-29
lines changed

7 files changed

+30
-29
lines changed

perf/src/deduper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ mod tests {
171171
let mut batches =
172172
to_packet_batches(&(0..1000).map(|_| test_tx()).collect::<Vec<_>>(), 128);
173173
discard += dedup_packets_and_count_discards(&filter, &mut batches) as usize;
174-
trace!("{} {}", i, discard);
174+
trace!("{i} {discard}");
175175
if filter.popcount.load(Ordering::Relaxed) > capacity {
176176
break;
177177
}

perf/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ pub fn report_target_features() {
6868
info!("AVX detected");
6969
} else {
7070
error!(
71-
"Incompatible CPU detected: missing AVX support. Please build from source on the target"
72-
);
71+
"Incompatible CPU detected: missing AVX support. Please build from source on \
72+
the target"
73+
);
7374
std::process::abort();
7475
}
7576
}
@@ -83,7 +84,8 @@ pub fn report_target_features() {
8384
info!("AVX2 detected");
8485
} else {
8586
error!(
86-
"Incompatible CPU detected: missing AVX2 support. Please build from source on the target"
87+
"Incompatible CPU detected: missing AVX2 support. Please build from source on \
88+
the target"
8789
);
8890
std::process::abort();
8991
}

perf/src/packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl PinnedPacketBatch {
685685
// TODO: This should never happen. Instead the caller should
686686
// break the payload into smaller messages, and here any errors
687687
// should be propagated.
688-
error!("Couldn't write to packet {:?}. Data skipped.", e);
688+
error!("Couldn't write to packet {e:?}. Data skipped.");
689689
packet.meta_mut().set_discard(true);
690690
}
691691
} else {

perf/src/perf_libs.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ pub struct Api<'a> {
8484
static API: OnceLock<Container<Api>> = OnceLock::new();
8585

8686
fn init(name: &OsStr) {
87-
info!("Loading {:?}", name);
87+
info!("Loading {name:?}");
8888
API.get_or_init(|| {
8989
unsafe { Container::load(name) }.unwrap_or_else(|err| {
90-
error!("Unable to load {:?}: {}", name, err);
90+
error!("Unable to load {name:?}: {err}");
9191
std::process::exit(1);
9292
})
9393
});
@@ -97,21 +97,21 @@ pub fn locate_perf_libs() -> Option<PathBuf> {
9797
let exe = env::current_exe().expect("Unable to get executable path");
9898
let perf_libs = exe.parent().unwrap().join("perf-libs");
9999
if perf_libs.is_dir() {
100-
info!("perf-libs found at {:?}", perf_libs);
100+
info!("perf-libs found at {perf_libs:?}");
101101
return Some(perf_libs);
102102
}
103-
warn!("{:?} does not exist", perf_libs);
103+
warn!("{perf_libs:?} does not exist");
104104
None
105105
}
106106

107107
fn find_cuda_home(perf_libs_path: &Path) -> Option<PathBuf> {
108108
if let Ok(cuda_home) = env::var("CUDA_HOME") {
109109
let path = PathBuf::from(cuda_home);
110110
if path.is_dir() {
111-
info!("Using CUDA_HOME: {:?}", path);
111+
info!("Using CUDA_HOME: {path:?}");
112112
return Some(path);
113113
}
114-
warn!("Ignoring CUDA_HOME, not a path: {:?}", path);
114+
warn!("Ignoring CUDA_HOME, not a path: {path:?}");
115115
}
116116

117117
// Search /usr/local for a `cuda-` directory that matches a perf-libs subdirectory
@@ -130,7 +130,7 @@ fn find_cuda_home(perf_libs_path: &Path) -> Option<PathBuf> {
130130
continue;
131131
}
132132

133-
info!("CUDA installation found at {:?}", cuda_home);
133+
info!("CUDA installation found at {cuda_home:?}");
134134
return Some(cuda_home);
135135
}
136136
None
@@ -141,7 +141,7 @@ pub fn append_to_ld_library_path(mut ld_library_path: String) {
141141
ld_library_path.push(':');
142142
ld_library_path.push_str(&env_value);
143143
}
144-
info!("setting ld_library_path to: {:?}", ld_library_path);
144+
info!("setting ld_library_path to: {ld_library_path:?}");
145145
env::set_var("LD_LIBRARY_PATH", ld_library_path);
146146
}
147147

@@ -154,7 +154,7 @@ pub fn init_cuda() {
154154
// to ensure the correct CUDA version is used
155155
append_to_ld_library_path(cuda_lib64_dir.to_str().unwrap_or("").to_string())
156156
} else {
157-
warn!("CUDA lib64 directory does not exist: {:?}", cuda_lib64_dir);
157+
warn!("CUDA lib64 directory does not exist: {cuda_lib64_dir:?}");
158158
}
159159

160160
let libcuda_crypt = perf_libs_path

perf/src/recycler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct RecyclerX<T> {
4747
impl<T: Default> Default for RecyclerX<T> {
4848
fn default() -> RecyclerX<T> {
4949
let id = thread_rng().gen_range(0..1000);
50-
trace!("new recycler..{}", id);
50+
trace!("new recycler..{id}");
5151
RecyclerX {
5252
gc: Mutex::default(),
5353
stats: RecyclerStats::default(),

perf/src/sigverify.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ pub fn shrink_batches(batches: Vec<PacketBatch>) -> Vec<PacketBatch> {
510510
}
511511

512512
pub fn ed25519_verify_cpu(batches: &mut [PacketBatch], reject_non_vote: bool, packet_count: usize) {
513-
debug!("CPU ECDSA for {}", packet_count);
513+
debug!("CPU ECDSA for {packet_count}");
514514
PAR_THREAD_POOL.install(|| {
515515
batches.par_iter_mut().flatten().for_each(|mut packet| {
516516
if !packet.meta().discard() && !verify_packet(&mut packet, reject_non_vote) {
@@ -522,7 +522,7 @@ pub fn ed25519_verify_cpu(batches: &mut [PacketBatch], reject_non_vote: bool, pa
522522

523523
pub fn ed25519_verify_disabled(batches: &mut [PacketBatch]) {
524524
let packet_count = count_packets_in_batches(batches);
525-
debug!("disabled ECDSA for {}", packet_count);
525+
debug!("disabled ECDSA for {packet_count}");
526526
PAR_THREAD_POOL.install(|| {
527527
batches.par_iter_mut().flatten().for_each(|mut packet| {
528528
packet.meta_mut().set_discard(false);
@@ -613,7 +613,7 @@ pub fn ed25519_verify(
613613
let (signature_offsets, pubkey_offsets, msg_start_offsets, msg_sizes, sig_lens) =
614614
generate_offsets(batches, recycler, reject_non_vote);
615615

616-
debug!("CUDA ECDSA for {}", valid_packet_count);
616+
debug!("CUDA ECDSA for {valid_packet_count}");
617617
debug!("allocating out..");
618618
let mut out = recycler_out.allocate("out_buffer");
619619
out.set_pinnable();
@@ -642,7 +642,7 @@ pub fn ed25519_verify(
642642
num_packets = num_packets.saturating_add(batch.len());
643643
}
644644
out.resize(signature_offsets.len(), 0);
645-
trace!("Starting verify num packets: {}", num_packets);
645+
trace!("Starting verify num packets: {num_packets}");
646646
trace!("elem len: {}", elems.len() as u32);
647647
trace!("packet sizeof: {}", size_of::<Packet>() as u32);
648648
trace!("len offset: {}", PACKET_DATA_SIZE as u32);
@@ -662,7 +662,7 @@ pub fn ed25519_verify(
662662
USE_NON_DEFAULT_STREAM,
663663
);
664664
if res != 0 {
665-
trace!("RETURN!!!: {}", res);
665+
trace!("RETURN!!!: {res}");
666666
}
667667
}
668668
trace!("done verify");
@@ -879,7 +879,7 @@ mod tests {
879879
let mut tx = Transaction::new_unsigned(message);
880880

881881
info!("message: {:?}", tx.message_data());
882-
info!("tx: {:?}", tx);
882+
info!("tx: {tx:?}");
883883
let sig = keypair1.try_sign_message(&tx.message_data()).unwrap();
884884
tx.signatures = vec![sig; NUM_SIG];
885885

@@ -1734,7 +1734,7 @@ mod tests {
17341734

17351735
let test_cases = set_discards.iter().zip(&expect_valids).enumerate();
17361736
for (i, (set_discard, (expect_batch_count, expect_valid_packets))) in test_cases {
1737-
debug!("test_shrink case: {}", i);
1737+
debug!("test_shrink case: {i}");
17381738
let mut batches = to_packet_batches(
17391739
&(0..PACKET_COUNT).map(|_| test_tx()).collect::<Vec<_>>(),
17401740
PACKETS_PER_BATCH,
@@ -1747,18 +1747,18 @@ mod tests {
17471747
.for_each(|(j, mut p)| p.meta_mut().set_discard(set_discard(i, j)))
17481748
});
17491749
assert_eq!(count_valid_packets(&batches), *expect_valid_packets);
1750-
debug!("show valid packets for case {}", i);
1750+
debug!("show valid packets for case {i}");
17511751
batches.iter_mut().enumerate().for_each(|(i, b)| {
17521752
b.iter_mut().enumerate().for_each(|(j, p)| {
17531753
if !p.meta().discard() {
1754-
trace!("{} {}", i, j)
1754+
trace!("{i} {j}")
17551755
}
17561756
})
17571757
});
1758-
debug!("done show valid packets for case {}", i);
1758+
debug!("done show valid packets for case {i}");
17591759
let batches = shrink_batches(batches);
17601760
let shrunken_batch_count = batches.len();
1761-
debug!("shrunk batch test {} count: {}", i, shrunken_batch_count);
1761+
debug!("shrunk batch test {i} count: {shrunken_batch_count}");
17621762
assert_eq!(shrunken_batch_count, *expect_batch_count);
17631763
assert_eq!(count_valid_packets(&batches), *expect_valid_packets);
17641764
}

perf/src/thread.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ where
8181
Ok(())
8282
} else {
8383
Err(String::from(
84-
"niceness adjustment supported only on Linux; negative adjustment \
85-
(priority increase) requires root or CAP_SYS_NICE (see `man 7 capabilities` \
86-
for details)",
84+
"niceness adjustment supported only on Linux; negative adjustment (priority increase) \
85+
requires root or CAP_SYS_NICE (see `man 7 capabilities` for details)",
8786
))
8887
}
8988
}

0 commit comments

Comments
 (0)