Add poh-bench (#10707)

This commit is contained in:
sakridge 2020-06-24 15:51:52 -07:00 committed by GitHub
parent 1c498369b5
commit 98621648cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 178 additions and 0 deletions

17
Cargo.lock generated
View File

@ -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"

View File

@ -31,6 +31,7 @@ members = [
"metrics",
"net-shaper",
"notifier",
"poh-bench",
"programs/bpf_loader",
"programs/budget",
"programs/btc_spv",

View File

@ -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 \

24
poh-bench/Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[package]
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
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"]

135
poh-bench/src/main.rs Normal file
View File

@ -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;
}
}