From 98621648cbab9d455b85691ac8fc3ebac6697eb0 Mon Sep 17 00:00:00 2001 From: sakridge Date: Wed, 24 Jun 2020 15:51:52 -0700 Subject: [PATCH] Add poh-bench (#10707) --- Cargo.lock | 17 ++++++ Cargo.toml | 1 + ci/test-stable.sh | 1 + poh-bench/Cargo.toml | 24 ++++++++ poh-bench/src/main.rs | 135 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 poh-bench/Cargo.toml create mode 100644 poh-bench/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 62bb29744..4834e8e04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4438,6 +4438,23 @@ dependencies = [ "solana-sdk 1.3.0", ] +[[package]] +name = "solana-poh-bench" +version = "1.3.0" +dependencies = [ + "clap", + "log 0.4.8", + "rand 0.7.3", + "rayon", + "solana-clap-utils", + "solana-ledger", + "solana-logger", + "solana-measure", + "solana-perf", + "solana-sdk 1.3.0", + "solana-version", +] + [[package]] name = "solana-ramp-tps" version = "1.3.0" diff --git a/Cargo.toml b/Cargo.toml index b708fa2e8..7879451cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ members = [ "metrics", "net-shaper", "notifier", + "poh-bench", "programs/bpf_loader", "programs/budget", "programs/btc_spv", diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 7d5f087a9..aa3f89814 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -65,6 +65,7 @@ test-stable-perf) _ cargo +"$rust_stable" build --bins ${V:+--verbose} _ cargo +"$rust_stable" test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture + _ cargo +"$rust_stable" run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10 ;; test-move) #ci/affects-files.sh \ diff --git a/poh-bench/Cargo.toml b/poh-bench/Cargo.toml new file mode 100644 index 000000000..4693033ff --- /dev/null +++ b/poh-bench/Cargo.toml @@ -0,0 +1,24 @@ +[package] +authors = ["Solana Maintainers "] +edition = "2018" +name = "solana-poh-bench" +version = "1.3.0" +repository = "https://github.com/solana-labs/solana" +license = "Apache-2.0" +homepage = "https://solana.com/" + +[dependencies] +clap = "2.33.1" +log = "0.4.6" +rand = "0.7.0" +rayon = "1.3.0" +solana-logger = { path = "../logger", version = "1.3.0" } +solana-ledger = { path = "../ledger", version = "1.3.0" } +solana-sdk = { path = "../sdk", version = "1.3.0" } +solana-clap-utils = { path = "../clap-utils", version = "1.3.0" } +solana-measure = { path = "../measure", version = "1.3.0" } +solana-version = { path = "../version", version = "1.3.0" } +solana-perf = { path = "../perf", version = "1.3.0" } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/poh-bench/src/main.rs b/poh-bench/src/main.rs new file mode 100644 index 000000000..78d59a881 --- /dev/null +++ b/poh-bench/src/main.rs @@ -0,0 +1,135 @@ +use clap::{crate_description, crate_name, value_t, App, Arg}; +use solana_ledger::entry::{self, create_ticks, init_poh, EntrySlice, VerifyRecyclers}; +use solana_measure::measure::Measure; +use solana_perf::perf_libs; +use solana_sdk::hash::hash; + +fn main() { + solana_logger::setup(); + + let matches = App::new(crate_name!()) + .about(crate_description!()) + .version(solana_version::version!()) + .arg( + Arg::with_name("max_num_entries") + .long("max-num-entries") + .takes_value(true) + .value_name("SIZE") + .help("Number of entries."), + ) + .arg( + Arg::with_name("start_num_entries") + .long("start-num-entries") + .takes_value(true) + .value_name("SIZE") + .help("Packets per chunk"), + ) + .arg( + Arg::with_name("hashes_per_tick") + .long("hashes-per-tick") + .takes_value(true) + .value_name("SIZE") + .help("hashes per tick"), + ) + .arg( + Arg::with_name("num_transactions_per_entry") + .long("num-transactions-per-entry") + .takes_value(true) + .value_name("NUM") + .help("Skip transaction sanity execution"), + ) + .arg( + Arg::with_name("iterations") + .long("iterations") + .takes_value(true) + .help("Number of iterations"), + ) + .arg( + Arg::with_name("num_threads") + .long("num-threads") + .takes_value(true) + .help("Number of threads"), + ) + .arg( + Arg::with_name("cuda") + .long("cuda") + .takes_value(false) + .help("Use cuda"), + ) + .get_matches(); + + let max_num_entries = value_t!(matches, "max_num_entries", u64).unwrap_or(64); + let start_num_entries = value_t!(matches, "start_num_entries", u64).unwrap_or(max_num_entries); + let iterations = value_t!(matches, "iterations", usize).unwrap_or(10); + let hashes_per_tick = value_t!(matches, "hashes_per_tick", u64).unwrap_or(10_000); + let start_hash = hash(&[1, 2, 3, 4]); + let ticks = create_ticks(max_num_entries, hashes_per_tick, start_hash); + let mut num_entries = start_num_entries as usize; + if matches.is_present("cuda") { + perf_libs::init_cuda(); + } + init_poh(); + while num_entries <= max_num_entries as usize { + let mut time = Measure::start("time"); + for _ in 0..iterations { + assert!(ticks[..num_entries] + .verify_cpu_generic(&start_hash) + .finish_verify(&ticks[..num_entries])); + } + time.stop(); + println!( + "{},cpu_generic,{}", + num_entries, + time.as_us() / iterations as u64 + ); + + if is_x86_feature_detected!("avx2") && entry::api().is_some() { + let mut time = Measure::start("time"); + for _ in 0..iterations { + assert!(ticks[..num_entries] + .verify_cpu_x86_simd(&start_hash, 8) + .finish_verify(&ticks[..num_entries])); + } + time.stop(); + println!( + "{},cpu_simd_avx2,{}", + num_entries, + time.as_us() / iterations as u64 + ); + } + + if is_x86_feature_detected!("avx512f") && entry::api().is_some() { + let mut time = Measure::start("time"); + for _ in 0..iterations { + assert!(ticks[..num_entries] + .verify_cpu_x86_simd(&start_hash, 16) + .finish_verify(&ticks[..num_entries])); + } + time.stop(); + println!( + "{},cpu_simd_avx512,{}", + num_entries, + time.as_us() / iterations as u64 + ); + } + + if perf_libs::api().is_some() { + let mut time = Measure::start("time"); + let recyclers = VerifyRecyclers::default(); + for _ in 0..iterations { + assert!(ticks[..num_entries] + .start_verify(&start_hash, recyclers.clone()) + .finish_verify(&ticks[..num_entries])); + } + time.stop(); + println!( + "{},gpu_cuda,{}", + num_entries, + time.as_us() / iterations as u64 + ); + } + + println!(); + num_entries *= 2; + } +}