From 007e28c6e32692b1d30cbb41a0c4e7b344c79e4e Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 30 May 2024 11:36:15 +0300 Subject: [PATCH] runner.sh: add --external flag for testing external network With --external flag bench will be run locally without docker container. The `-a` flag should be used with the `-e` flag for specifying the external RPC address. Close #160 Signed-off-by: Ekaterina Pavlova --- Makefile | 2 ++ README.md | 32 ++++++++++++++++++++++++++++++++ runner.sh | 19 +++++++++++++++---- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 74b92c1..d260b4e 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,8 @@ stop: @docker compose -f $(DC_GO_IR) -f $(DC_GO_7_IR) -f $(DC_GO_RPC) -f $(DC_GO_7_RPC) \ -f $(DC_GO_IR_SINGLE) -f $(DC_SINGLE) -f $(DC_SHARP_IR) -f $(DC_SHARP_7_IR) \ -f $(DC_SHARP_RPC) -f $(DC_SHARP_7_RPC) -f $(DC_SHARP_IR_SINGLE) down --remove-orphans &> /dev/null + @echo "=> Stop Bench process" + + @killall -w -v -INT bench > /dev/null 2>&1 || : # Check that all images were built check.images: diff --git a/README.md b/README.md index fde0c91..6d48a53 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,36 @@ $ ./runner.sh --validators 1 --nodes sharp -d "SharpSingle" -m rate -q 25 -z 5m $ ./runner.sh --nodes mixed -d "MixedGoRPC4x1" -m rate -q 50 -z 5m -t 30s ... ``` +## Usage example (local benchmark + external cluster) + +NeoBench can be run in a stand-alone mode (loader only) to benchmark some external network. +NeoBench expects external network to be launched with the known set of validators and committee (with wallets from `./docker/ir/`) +and not contain any transactions in the network (to successfully perform initial NEO/GAS transfers). In this setup the +loader will be launched as a system process, without Docker container. You have to provide RPS address(-es) of some +node from the external network to the loader instance on start. The loader will use the provided RPC to send +transactions to the network. + +1. Build the benchmark binary file with the following command: +``` +$ make build +=> Building Bench image registry.nspcc.ru/neo-bench/neo-bench:bench +sha256:b08f9fd42198be6c351d725543ac1e451063d18018a738f2446678a0cdf8ee78 +=> Building Go Node image registry.nspcc.ru/neo-bench/neo-go:bench +sha256:2bf655747dfa06b85ced1ad7f0257128e7261e6d16b2c8087bc16fd27fcb3a6d +=> Building Sharp Node image registry.nspcc.ru/neo-bench/neo-sharp:bench +sha256:a6ed753e8f81fedf8a9be556e60c6a41e385dd1ab2c90755ab44e2ceab92bca2 +=> Building Bench binary file ++ export GOGC=off ++ GOGC=off ++ export CGO_ENABLED=0 ++ CGO_ENABLED=0 ++ go -C cmd build -v -o bin/bench -trimpath ./bench +``` + +2. Run benchmarks using the `runner.sh` script with RPC address(-es) of the external network and `--external` flag set: +``` +$ ./runner.sh -e -d "Go4x1" -m rate -q 1000 -z 5m -t 30s -a 192.168.1.100:20331 -a 192.168.1.101:20331 +``` ## Benchmark usage @@ -307,6 +337,7 @@ The following default configurations are available: --msPerBlock Protocol setting specifying the minimal (and targeted for) time interval between blocks. Must be an integer number of milliseconds. The default value is set in configuration templates and is 1s and 5s for single node and multinode setup respectively. Example: --msPerBlock 3000 + -e, --external Use external network for benchmarking. Default is false. -a flag should be used to specify RPC addresses. ``` @@ -314,6 +345,7 @@ The following default configurations are available: By default, neo-bench uses released versions of Neo nodes to build Docker images. However, you can easily test non-released branches or even separate commits for both Go and C# Neo nodes. +`--external` flag should be used for external network benchmarks to run the loader in a standalone mode without Docker container. ### Build Go node image from sources diff --git a/runner.sh b/runner.sh index 1aeab3b..987bca2 100755 --- a/runner.sh +++ b/runner.sh @@ -3,7 +3,7 @@ source .env OUTPUT="" -ARGS=(-i "/dump.txs") +ARGS=() FILES=() MODE="" TARGET_RPS="" @@ -12,6 +12,7 @@ WORKERS_COUNT="30" IR_TYPE=go RPC_TYPE= RPC_ADDR=() +EXTERNAL_NETWORK=false export NEOBENCH_LOGGER=${NEOBENCH_LOGGER:-none} export NEOBENCH_TYPE=${NEOBENCH_TYPE:-NEO} export NEOBENCH_FROM_COUNT=${NEOBENCH_FROM_COUNT:-1} @@ -56,6 +57,7 @@ show_help() { echo " --msPerBlock Protocol setting specifying the minimal (and targeted for) time interval between blocks. Must be an integer number of milliseconds." echo " The default value is set in configuration templates and is 1s and 5s for single node and multinode setup respectively." echo " Example: --msPerBlock 1000" + echo " -e, --external Use external network for benchmarking. Default is false. -a flag should be used to specify RPC addresses." exit 0 } @@ -74,6 +76,9 @@ while test $# -gt 0; do case $_opt in -h | --help) show_help ;; + -e|--external) + EXTERNAL_NETWORK=true + ;; -l | --log) if [[ $# -gt 0 && ${1:0:1} != "-" ]]; then case "$1" in @@ -280,7 +285,13 @@ if [ -n "$NEOBENCH_VOTE" ]; then fi make prepare - -docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}" - +if [ "$EXTERNAL_NETWORK" = true ]; then + ARGS+=(-i "./.docker/build/dump.$NEOBENCH_TYPE.$NEOBENCH_FROM_COUNT.$NEOBENCH_TO_COUNT.txs" --disable-stats) + ./cmd/bin/bench -o "$OUTPUT" "${ARGS[@]}"& + pid=$! + wait $pid +else + ARGS+=(-i "/dump.txs") + docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}" +fi make stop