Skip to content

Commit

Permalink
runner.sh: add --external flag for testing external network
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AliceInHunterland committed May 30, 2024
1 parent 1fdda2a commit 007e28c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -307,13 +337,15 @@ 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.
```

## Build options

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

Expand Down
19 changes: 15 additions & 4 deletions runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source .env

OUTPUT=""
ARGS=(-i "/dump.txs")
ARGS=()
FILES=()
MODE=""
TARGET_RPS=""
Expand All @@ -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}
Expand Down Expand Up @@ -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
}

Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 007e28c

Please sign in to comment.