client changes for TODOs and looping (#1138)

* remove client.sh from snap
* default to ephemeral instead of ~/.config key
* rework CLI for bench-tps
* remote multinode-demo stuff from remote-client.sh
* remove multinode-demo from remote-sanity and localnet-sanity
This commit is contained in:
Rob Walker
2018-09-08 07:07:10 +09:00
committed by GitHub
parent 5169c8d08f
commit 51b27779c9
6 changed files with 85 additions and 88 deletions

View File

@ -70,7 +70,11 @@ echo "--- Wallet sanity"
echo "--- Node count" echo "--- Node count"
( (
set -x set -x
./multinode-demo/client.sh --num-nodes 3 --converge-only source multinode-demo/common.sh
client_id=/tmp/client-id.json-$$
$solana_keygen -o $client_id
$solana_bench_tps --identity $client_id --num-nodes 3 --converge-only
rm -rf $client_id
) || flag_error ) || flag_error
killBackgroundCommands killBackgroundCommands

View File

@ -9,33 +9,13 @@ usage() {
echo "$*" echo "$*"
echo echo
fi fi
echo "usage: $0 [network entry point] [extra args]" echo "usage: $0 [extra args]"
echo echo
echo " Run bench-tps against the specified network" echo " Run bench-tps "
echo echo
echo " extra args: additional arguments are pass along to solana-bench-tps" echo " extra args: additional arguments are pass along to solana-bench-tps"
echo echo
exit 1 exit 1
} }
# This is a little hacky $solana_bench_tps "$@"
if [[ ${1:0:2} != "--" ]]; then
if [[ ${2:0:2} != "--" ]]; then
read -r _ leader_address shift < <(find_leader "${@:1:2}")
else
read -r _ leader_address shift < <(find_leader "${@:1:1}")
fi
else
read -r _ leader_address shift < <(find_leader)
fi
shift "$shift"
client_json="$SOLANA_CONFIG_CLIENT_DIR"/client.json
[[ -r $client_json ]] || $solana_keygen -o "$client_json"
set -x
$solana_bench_tps \
--network "$leader_address" \
--keypair "$SOLANA_CONFIG_CLIENT_DIR"/client.json \
"$@"

View File

@ -32,16 +32,8 @@ snap)
sudo snap install solana.snap --devmode --dangerous sudo snap install solana.snap --devmode --dangerous
rm solana.snap rm solana.snap
nodeConfig="\
leader-ip=$entrypointIp \
default-metrics-rate=1 \
metrics-config=$SOLANA_METRICS_CONFIG \
rust-log=$RUST_LOG \
"
# shellcheck disable=SC2086 # Don't want to double quote "$nodeConfig"
sudo snap set solana $nodeConfig
solana_bench_tps=/snap/bin/solana.bench-tps solana_bench_tps=/snap/bin/solana.bench-tps
solana_keygen=/snap/bin/solana.keygen
;; ;;
local) local)
PATH="$HOME"/.cargo/bin:"$PATH" PATH="$HOME"/.cargo/bin:"$PATH"
@ -50,7 +42,8 @@ local)
export RUST_LOG export RUST_LOG
rsync -vPrc "$entrypointIp:~/.cargo/bin/solana*" ~/.cargo/bin/ rsync -vPrc "$entrypointIp:~/.cargo/bin/solana*" ~/.cargo/bin/
solana_bench_tps="multinode-demo/client.sh $entrypointIp:~/solana $entrypointIp:8001" solana_bench_tps=solana-bench-tps
solana_keygen=solana-keygen
;; ;;
*) *)
echo "Unknown deployment method: $deployMethod" echo "Unknown deployment method: $deployMethod"
@ -62,7 +55,13 @@ scripts/oom-monitor.sh > oom-monitor.log 2>&1 &
! tmux list-sessions || tmux kill-session ! tmux list-sessions || tmux kill-session
clientCommand="$solana_bench_tps --num-nodes $numNodes --seconds 600 --sustained --threads $threadCount" clientCommand="$solana_bench_tps --num-nodes $numNodes --seconds 600 --sustained --threads $threadCount"
keygenCommand="$solana_keygen -o client.id"
tmux new -s solana-bench-tps -d " tmux new -s solana-bench-tps -d "
[[ -r client.json ]] || {
echo '$ $keygenCommand' >> client.log
$keygenCommand >> client.log 2>&1
}
while true; do while true; do
echo === Client start: \$(date) >> client.log echo === Client start: \$(date) >> client.log
$metricsWriteDatapoint 'testnet-deploy client-begin=1' $metricsWriteDatapoint 'testnet-deploy client-begin=1'

View File

@ -51,22 +51,27 @@ case $deployMethod in
snap) snap)
PATH="/snap/bin:$PATH" PATH="/snap/bin:$PATH"
export USE_SNAP=1 export USE_SNAP=1
entrypointRsyncUrl="$entrypointIp"
solana_bench_tps=solana.bench-tps solana_bench_tps=solana.bench-tps
solana_ledger_tool=solana.ledger-tool solana_ledger_tool=solana.ledger-tool
ledger=/var/snap/solana/current/config/ledger solana_keygen=solana.keygen
ledger=/var/snap/solana/current/config/ledger
client_id=/var/snap/solana/current/config/client-id.json
entrypointRsyncUrl="$entrypointIp"
;; ;;
local) local)
PATH="$HOME"/.cargo/bin:"$PATH" PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1 export USE_INSTALL=1
entrypointRsyncUrl="$entrypointIp:~/solana" entrypointRsyncUrl="$entrypointIp:~/solana"
solana_bench_tps="multinode-demo/client.sh $entrypointRsyncUrl $entrypointIp:8001" solana_bench_tps=solana-bench-tps
solana_ledger_tool=solana-ledger-tool solana_ledger_tool=solana-ledger-tool
solana_keygen=solana-keygen
ledger=config/ledger ledger=config/ledger
client_id=config/client-id.json
;; ;;
*) *)
echo "Unknown deployment method: $deployMethod" echo "Unknown deployment method: $deployMethod"
@ -83,7 +88,8 @@ echo "--- $entrypointIp: wallet sanity"
echo "--- $entrypointIp: node count" echo "--- $entrypointIp: node count"
( (
set -x set -x
$solana_bench_tps --num-nodes "$numNodes" --converge-only [[ -r $client_id ]] || $solana_keygen -o "$client_id"
$solana_bench_tps --network "$entrypointIp:8001" --identity "$client_id" --num-nodes "$numNodes" --converge-only
) )
echo "--- $entrypointIp: verify ledger" echo "--- $entrypointIp: verify ledger"
@ -128,4 +134,3 @@ else
echo "^^^ +++" echo "^^^ +++"
echo "Validator sanity disabled (NO_VALIDATOR_SANITY defined)" echo "Validator sanity disabled (NO_VALIDATOR_SANITY defined)"
fi fi

View File

@ -49,9 +49,7 @@ apps:
plugs: plugs:
- home - home
bench-tps: bench-tps:
# TODO: Merge client.sh functionality into solana-bench-tps proper command: solana-bench-tps
command: multinode-demo/client.sh
#command: solana-bench-tps
plugs: plugs:
- network - network
- network-bind - network-bind

View File

@ -4,6 +4,7 @@ extern crate clap;
extern crate influx_db_client; extern crate influx_db_client;
extern crate rayon; extern crate rayon;
extern crate serde_json; extern crate serde_json;
#[macro_use]
extern crate solana; extern crate solana;
use clap::{App, Arg}; use clap::{App, Arg};
@ -401,11 +402,6 @@ fn should_switch_directions(num_tokens_per_account: i64, i: i64) -> bool {
fn main() { fn main() {
logger::setup(); logger::setup();
metrics::set_panic_hook("bench-tps"); metrics::set_panic_hook("bench-tps");
let mut threads = 4usize;
let mut num_nodes = 1usize;
let mut time_sec = 90;
let mut sustained = false;
let mut tx_count = 500_000;
let matches = App::new("solana-bench-tps") let matches = App::new("solana-bench-tps")
.version(crate_version!()) .version(crate_version!())
@ -415,17 +411,16 @@ fn main() {
.long("network") .long("network")
.value_name("HOST:PORT") .value_name("HOST:PORT")
.takes_value(true) .takes_value(true)
.required(true) .help("rendezvous with the network at this gossip entry point, defaults to 127.0.0.1:8001"),
.help("rendezvous with the network at this gossip entry point"),
) )
.arg( .arg(
Arg::with_name("keypair") Arg::with_name("identity")
.short("k") .short("i")
.long("keypair") .long("identity")
.value_name("PATH") .value_name("PATH")
.takes_value(true) .takes_value(true)
.default_value("~/.config/solana/id.json") .required(true)
.help("/path/to/id.json"), .help("file containing a client identity (keypair)"),
) )
.arg( .arg(
Arg::with_name("num-nodes") Arg::with_name("num-nodes")
@ -444,63 +439,68 @@ fn main() {
.help("number of threads"), .help("number of threads"),
) )
.arg( .arg(
Arg::with_name("seconds") Arg::with_name("duration")
.short("s") .long("duration")
.long("seconds") .value_name("SECS")
.value_name("NUM")
.takes_value(true) .takes_value(true)
.help("send transactions for this many seconds"), .help("run benchmark for SECS seconds then exit, default is forever"),
) )
.arg( .arg(
Arg::with_name("converge-only") Arg::with_name("converge-only")
.short("c")
.long("converge-only") .long("converge-only")
.help("exit immediately after converging"), .help("exit immediately after converging"),
) )
.arg( .arg(
Arg::with_name("sustained") Arg::with_name("sustained")
.long("sustained") .long("sustained")
.help("Use sustained performance mode vs. peak mode. This overlaps the tx generation with transfers."), .help("use sustained performance mode vs. peak mode. This overlaps the tx generation with transfers."),
) )
.arg( .arg(
Arg::with_name("tx_count") Arg::with_name("tx_count")
.long("tx_count") .long("tx_count")
.value_name("NUMBER") .value_name("NUM")
.takes_value(true) .takes_value(true)
.help("number of transactions to send in a single batch") .help("number of transactions to send per batch")
) )
.get_matches(); .get_matches();
let network = matches let network = if let Some(addr) = matches.value_of("network") {
.value_of("network") addr.parse().unwrap_or_else(|e| {
.unwrap()
.parse()
.unwrap_or_else(|e| {
eprintln!("failed to parse network: {}", e); eprintln!("failed to parse network: {}", e);
exit(1) exit(1)
}); })
} else {
socketaddr!("127.0.0.1:8001")
};
let id = read_keypair(matches.value_of("keypair").unwrap()).expect("client keypair"); let id =
read_keypair(matches.value_of("identity").unwrap()).expect("can't read client identity");
if let Some(t) = matches.value_of("threads") { let threads = if let Some(t) = matches.value_of("threads") {
threads = t.to_string().parse().expect("integer"); t.to_string().parse().expect("can't parse threads")
} } else {
4usize
};
if let Some(n) = matches.value_of("num-nodes") { let num_nodes = if let Some(n) = matches.value_of("num-nodes") {
num_nodes = n.to_string().parse().expect("integer"); n.to_string().parse().expect("can't parse num-nodes")
} } else {
1usize
};
if let Some(s) = matches.value_of("seconds") { let duration = if let Some(s) = matches.value_of("duration") {
time_sec = s.to_string().parse().expect("integer"); Duration::new(s.to_string().parse().expect("can't parse duration"), 0)
} } else {
Duration::new(std::u64::MAX, 0)
};
if let Some(s) = matches.value_of("tx_count") { let tx_count = if let Some(s) = matches.value_of("tx_count") {
tx_count = s.to_string().parse().expect("integer"); s.to_string().parse().expect("can't parse tx_count")
} } else {
500_000
};
if matches.is_present("sustained") { let sustained = matches.is_present("sustained");
sustained = true;
}
let leader = poll_gossip_for_leader(network, None).expect("unable to find leader on network"); let leader = poll_gossip_for_leader(network, None).expect("unable to find leader on network");
@ -617,11 +617,12 @@ fn main() {
.collect(); .collect();
// generate and send transactions for the specified duration // generate and send transactions for the specified duration
let time = Duration::new(time_sec, 0);
let now = Instant::now(); let now = Instant::now();
let mut last_stat = Instant::now();
let stat_interval = Duration::new(90, 0);
let mut reclaim_tokens_back_to_source_account = false; let mut reclaim_tokens_back_to_source_account = false;
let mut i = keypair0_balance; let mut i = keypair0_balance;
while now.elapsed() < time { while now.elapsed() < duration {
let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(-1); let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(-1);
metrics_submit_token_balance(balance); metrics_submit_token_balance(balance);
@ -653,6 +654,16 @@ fn main() {
if should_switch_directions(num_tokens_per_account, i) { if should_switch_directions(num_tokens_per_account, i) {
reclaim_tokens_back_to_source_account = !reclaim_tokens_back_to_source_account; reclaim_tokens_back_to_source_account = !reclaim_tokens_back_to_source_account;
} }
if last_stat.elapsed() >= stat_interval {
last_stat = Instant::now();
compute_and_report_stats(
&maxes,
sample_period,
&now.elapsed(),
total_tx_sent_count.load(Ordering::Relaxed),
);
}
} }
// Stop the sampling threads so it will collect the stats // Stop the sampling threads so it will collect the stats