Skip to content

Commit

Permalink
*: add -e and --disable-stats flags for testing external network
Browse files Browse the repository at this point in the history
With the `-e` flag bench without the docker container will be started.
The `-a` flag should be used with the `-e` flag for specifying the
external RPC address. To disable collection of docker container

Close #160

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed May 21, 2024
1 parent ee16e47 commit 5bd3ede
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ $ ./runner.sh --nodes mixed -d "MixedGoRPC4x1" -m rate -q 50 -z 5m -t 30s
-i, --in Path to input file to load transactions.
Example: -i ./dump.txs --in /path/to/import/transactions
--vote Vote before the bench.
--disable-stats Disable memory and CPU usage statistics collection.
````

## Makefile usage
Expand Down Expand Up @@ -300,6 +301,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.
```

Expand Down
42 changes: 22 additions & 20 deletions cmd/bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func main() {
timeLimit = v.GetDuration("timeLimit")
mode = internal.BenchMode(v.GetString("mode"))
client *internal.RPCClient
disableStats = v.GetBool("disable-stats")
)

switch mode {
Expand Down Expand Up @@ -98,32 +99,33 @@ func main() {
log.Fatalf("could not close report: %v", err)
}
}()
if !disableStats {
statsPeriod := time.Second

statsPeriod := time.Second
ds, err := internal.NewStats(ctx,
internal.StatEnableLogger(),
internal.StatPeriod(statsPeriod),
internal.StatCriteria([]string{"stats"}),
internal.StatListVerifier(func(list []types.Container) error {
if len(list) == 0 {
return errors.New("containers not found by criteria")
}

ds, err := internal.NewStats(ctx,
internal.StatEnableLogger(),
internal.StatPeriod(statsPeriod),
internal.StatCriteria([]string{"stats"}),
internal.StatListVerifier(func(list []types.Container) error {
if len(list) == 0 {
return errors.New("containers not found by criteria")
}
return nil
}))

return nil
}))
if err != nil {
log.Fatalf("could not create docker stats grabber: %v", err)
}

if err != nil {
log.Fatalf("could not create docker stats grabber: %v", err)
statsStart := time.Now()
// Run stats worker:
go ds.Run(ctx, func(cpu, mem float64) {
rep.UpdateRes(statsStart, cpu, mem)
log.Printf("CPU: %0.3f%%, Mem: %0.3fMB", cpu, mem)
})
}

statsStart := time.Now()
// Run stats worker:
go ds.Run(ctx, func(cpu, mem float64) {
rep.UpdateRes(statsStart, cpu, mem)
log.Printf("CPU: %0.3f%%, Mem: %0.3fMB", cpu, mem)
})

if in := v.GetString("in"); in != "" {
dump = internal.ReadDump(in)
} else {
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func InitSettings() *viper.Viper {
"Example: -i ./dump.txs --in /path/to/import/transactions")

flags.BoolP("vote", "", false, "Vote before the bench.")
flags.BoolP("disable-stats", "", false, "Disable memory and CPU usage statistics collection.")

if err := v.BindPFlags(flags); err != nil {
panic(err)
Expand Down
21 changes: 18 additions & 3 deletions runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
source .env

OUTPUT=""
ARGS=(-i "/dump.txs")
ARGS=()
FILES=()
MODE=""
COUNT=""
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 @@ -54,6 +55,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."
exit 0
}

Expand All @@ -72,6 +74,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 @@ -273,7 +278,17 @@ if [ -n "$NEOBENCH_VOTE" ]; then
fi

make prepare
if [ "$EXTERNAL_NETWORK" = true ]; then
ARGS+=(-i "./.docker/build/dump.$NEOBENCH_TYPE.$NEOBENCH_FROM_COUNT.$NEOBENCH_TO_COUNT.txs" --disable-stats)

docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}"
make build.binary.bench

make stop
./cmd/bin/bench -o "$OUTPUT" "${ARGS[@]}"

else
ARGS+=(-i "/dump.txs")

docker compose "${FILES[@]}" run bench neo-bench -o "$OUTPUT" "${ARGS[@]}"

make stop
fi

0 comments on commit 5bd3ede

Please sign in to comment.