Skip to content

Commit 84563db

Browse files
committed
test_aggregation_throughput_per_num_xmss
1 parent 632ce32 commit 84563db

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

crates/rec_aggregation/src/benchmark.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub fn run_aggregation_benchmark(topology: &AggregationTopology, overlap: usize,
304304

305305
let n_sigs = count_signers(topology, overlap);
306306

307-
let cache = read_benchmark_signers_cache();
307+
let cache = get_benchmark_signers_cache();
308308
assert!(cache.len() >= n_sigs);
309309
let paired: Vec<_> = (0..n_sigs)
310310
.into_par_iter()
@@ -334,3 +334,50 @@ pub fn run_aggregation_benchmark(topology: &AggregationTopology, overlap: usize,
334334
let message = message_for_benchmark();
335335
crate::verify_aggregation(&aggregated_sigs, &message, BENCHMARK_SLOT).unwrap();
336336
}
337+
338+
#[test]
339+
#[ignore]
340+
fn test_aggregation_throughput_per_num_xmss() {
341+
let log_inv_rate = 1;
342+
precompute_dft_twiddles::<F>(1 << 24);
343+
init_aggregation_bytecode();
344+
let _ = get_aggregation_bytecode();
345+
let mut num_xmss_and_time = vec![];
346+
let mut indexes = vec![];
347+
for i in 1..100 {
348+
indexes.push(i * 10);
349+
}
350+
for i in 50..100 {
351+
indexes.push(i * 20);
352+
}
353+
for i in 40..60 {
354+
indexes.push(i * 50);
355+
}
356+
for num_xmss in indexes {
357+
let topology = AggregationTopology {
358+
raw_xmss: num_xmss,
359+
children: vec![],
360+
log_inv_rate,
361+
};
362+
let instant = Instant::now();
363+
run_aggregation_benchmark(&topology, 0, false);
364+
let elapsed = instant.elapsed();
365+
num_xmss_and_time.push((num_xmss, elapsed.as_secs_f64()));
366+
println!(
367+
"{} XMSS -> {} XMSS/s",
368+
num_xmss,
369+
(num_xmss as f64 / elapsed.as_secs_f64()).round() as usize
370+
);
371+
372+
std::thread::sleep(std::time::Duration::from_millis(1000));
373+
374+
let mut csv = String::from("num_sigs,throughput (XMSS/s)\n");
375+
for &(n, t) in &num_xmss_and_time {
376+
csv.push_str(&format!("{},{:.1}\n", n, n as f64 / t));
377+
}
378+
let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("benchmarks/xmss_throughput.csv");
379+
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
380+
std::fs::write(&path, &csv).unwrap();
381+
println!("\nWrote {}", path.display());
382+
}
383+
}

crates/xmss/src/signers_cache.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
use std::path::PathBuf;
2+
use std::sync::OnceLock;
23

34
use backend::*;
45
use rand::rngs::StdRng;
56
use rand::{Rng, SeedableRng};
67

78
use crate::*;
89

10+
static SIGNERS_CACHE: OnceLock<Vec<[F; RANDOMNESS_LEN_FE]>> = OnceLock::new();
11+
12+
pub fn get_benchmark_signers_cache() -> &'static Vec<[F; RANDOMNESS_LEN_FE]> {
13+
SIGNERS_CACHE.get_or_init(read_benchmark_signers_cache)
14+
}
15+
916
pub const BENCHMARK_SLOT: u32 = 1111;
1017

1118
pub fn message_for_benchmark() -> [F; MESSAGE_LEN_FE] {

0 commit comments

Comments
 (0)