[benchmarks] Refactor benchmarking scripts to extract common concerns.

This commit is contained in:
Ciprian Dorin Craciun 2021-12-23 16:52:24 +02:00
parent 1175a6adb6
commit 24aa5198e7
3 changed files with 185 additions and 132 deletions

View file

@ -1,7 +1,7 @@
master_process on; master_process off;
worker_processes 2; worker_processes 0;
worker_rlimit_nofile 131072; worker_rlimit_nofile 131072;
events { events {

View file

@ -5,10 +5,8 @@
:: benchmark / server / http-fast / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 1 --threads 1 :: benchmark / server / http-fast / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 1 --threads 1
:: benchmark / server / http-fast / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 2 --threads 1 :: benchmark / server / http-fast / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 2 --threads 1
:: benchmark / server / http-fast / 4x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 4 --threads 1
:: benchmark / server / http-fast / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 1 --threads 2 :: benchmark / server / http-fast / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 1 --threads 2
:: benchmark / server / http-fast / 2x2 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 2 --threads 2 :: benchmark / server / http-fast / 2x2 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 2 --threads 2
:: benchmark / server / http-fast / 1x4 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-fast "${@}" --processes 1 --threads 4
:: benchmark / server / http-go / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-go "${@}" --processes 1 --threads 1 :: benchmark / server / http-go / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-go "${@}" --processes 1 --threads 1
:: benchmark / server / http-go / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-go "${@}" --processes 2 --threads 1 :: benchmark / server / http-go / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-go "${@}" --processes 2 --threads 1
@ -252,15 +250,8 @@
;; ;;
esac esac
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / server' \
sudo -u root -n -E -P -- \ noenvironment \
taskset -c 0,1 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i -- \
./.outputs/binaries/release/kawipiko-server \ ./.outputs/binaries/release/kawipiko-server \
"${_arguments[@]}" \ "${_arguments[@]}" \
--archive "${_archive}" \ --archive "${_archive}" \
@ -309,12 +300,22 @@
<< benchmark / server / profile / cpu / analyze << benchmark / server / profile / cpu / analyze
export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server
exec -- go tool pprof "${@}" -- ./.outputs/server-cpu.txt exec -- go tool pprof \
"${@}" \
-- ./.outputs/server-cpu.txt \
#
!! !!
<< benchmark / server / profile / cpu / analyze / web << benchmark / server / profile / cpu / analyze / web
export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server
exec -- go tool pprof -http 127.108.221.132:8080 -no_browser -functions -nodefraction 0 "${@}" -- ./.outputs/server-cpu.txt exec -- go tool pprof \
-http 127.108.221.132:8080 \
-no_browser \
-functions \
-nodefraction 0 \
"${@}" \
-- ./.outputs/server-cpu.txt \
#
!! !!
<< benchmark / server / profile / cpu / analyze / web-open << benchmark / server / profile / cpu / analyze / web-open
@ -325,12 +326,22 @@
<< benchmark / server / profile / mem / analyze << benchmark / server / profile / mem / analyze
export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server
exec -- go tool pprof "${@}" -- ./.outputs/server-mem.txt exec -- go tool pprof \
"${@}" \
-- ./.outputs/server-mem.txt \
#
!! !!
<< benchmark / server / profile / mem / analyze / web << benchmark / server / profile / mem / analyze / web
export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server
exec -- go tool pprof -http 127.226.119.8:8080 -no_browser -functions -nodefraction 0 "${@}" -- ./.outputs/server-mem.txt exec -- go tool pprof \
-http 127.226.119.8:8080 \
-no_browser \
-functions \
-nodefraction 0 \
"${@}" \
-- ./.outputs/server-mem.txt \
#
!! !!
<< benchmark / server / profile / mem / analyze / web-open << benchmark / server / profile / mem / analyze / web-open
@ -341,24 +352,24 @@
:: benchmark / dummy / fasthttp / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 "${@}" :: benchmark / dummy / fasthttp / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 1 "${@}"
:: benchmark / dummy / fasthttp / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 "${@}" :: benchmark / dummy / fasthttp / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 2 "${@}"
:: benchmark / dummy / fasthttp / 1x4 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 4 "${@}" :: benchmark / dummy / fasthttp / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 1 "${@}"
:: benchmark / dummy / fasthttp / 2x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 2 "${@}"
--<< benchmark / dummy / fasthttp --<< benchmark / dummy / fasthttp
"${ZRUN[@]}" ':: go / build / server-dummy / release / quick' "${ZRUN[@]}" ':: go / build / server-dummy / release / quick'
test "${#}" -ge 2
_count="${1}"
_threads="${2}"
shift -- 2
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
sudo -u root -n -E -P -- \ "${ZRUN[@]}" ':: benchmark / execute / server' \
taskset -c 0,1 \ noenvironment \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i -- \
./.outputs/binaries/release/kawipiko-server-dummy \ ./.outputs/binaries/release/kawipiko-server-dummy \
"127.9.185.194:8080" \ "127.9.185.194:8080" \
"${_threads}" \
"${@}" \ "${@}" \
# #
!! !!
@ -366,15 +377,8 @@
<< benchmark / dummy / haproxy / 1x2 << benchmark / dummy / haproxy / 1x2
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / server' \
sudo -u root -n -E -P -- \ noenvironment \
taskset -c 0,1 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i -- \
./.bin/haproxy \ ./.bin/haproxy \
-db \ -db \
-f ./examples/dummy/haproxy-dummy.conf \ -f ./examples/dummy/haproxy-dummy.conf \
@ -383,17 +387,17 @@
!! !!
<< benchmark / dummy / nginx / 2x1 :: benchmark / dummy / nginx / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / nginx' 1 "${@}"
:: benchmark / dummy / nginx / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / nginx' 2 "${@}"
--<< benchmark / dummy / nginx
test "${#}" -ge 1
_count="${1}"
shift -- 1
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
sudo -u root -n -E -P -- \ "${ZRUN[@]}" ':: benchmark / execute / server' \
taskset -c 0,1 \ noenvironment \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i -- \
./.bin/nginx \ ./.bin/nginx \
-c ./examples/dummy/nginx-dummy.conf \ -c ./examples/dummy/nginx-dummy.conf \
-e /dev/stderr \ -e /dev/stderr \
@ -403,17 +407,16 @@
!! !!
<< benchmark / dummy / nodejs / 1x1 :: benchmark / dummy / nodejs / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / nodejs' 1 "${@}"
--<< benchmark / dummy / nodejs
test "${#}" -ge 1
_count="${1}"
shift -- 1
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
sudo -u root -n -E -P -- \ "${ZRUN[@]}" ':: benchmark / execute / server' \
taskset -c 0,1 \ noenvironment \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i -- \
./.bin/node16 \ ./.bin/node16 \
-- \ -- \
./examples/dummy/nodejs-dummy.js \ ./examples/dummy/nodejs-dummy.js \
@ -423,36 +426,17 @@
!! !!
<< benchmark / dummy / httpterm / 2x1 :: benchmark / dummy / httpterm / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / httpterm' 1 "${@}"
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )" :: benchmark / dummy / httpterm / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / httpterm' 2 "${@}"
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / dummy / httpterm / 2x1' "${@}"
fi
_pids=()
"${ZRUN[@]}" ':: benchmark / dummy / httpterm / 1x1' "${@}" & _pids+=( "${!}" )
"${ZRUN[@]}" ':: benchmark / dummy / httpterm / 1x1' "${@}" & _pids+=( "${!}" )
(
trap 'kill -- "${_pids[@]}" 2> /dev/null || true' SIGINT SIGTERM SIGQUIT
while sleep 1m ; do true ; done || true
kill -- "${_pids[@]}" 2> /dev/null || true
) &
exit -- 0
!!
<< benchmark / dummy / httpterm / 1x1 --<< benchmark / dummy / httpterm
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )" test "${#}" -ge 1
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then _count="${1}"
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / dummy / httpterm / 1x1' "${@}" shift -- 1
fi
exec -- \ exec -- \
sudo -u root -n -E -P -- \ "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
taskset -c 0,1 \ "${ZRUN[@]}" ':: benchmark / execute / server' \
nice -n -19 -- \ noenvironment \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
env -i \
./.bin/httpterm \ ./.bin/httpterm \
-db \ -db \
-L 127.9.185.194:8080 \ -L 127.9.185.194:8080 \
@ -491,14 +475,7 @@
_path='' _path=''
fi fi
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / client' \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${ZRUN[@]}" ':: tools / wrk' \ "${ZRUN[@]}" ':: tools / wrk' \
"${@}" \ "${@}" \
-- \ -- \
@ -525,14 +502,7 @@
_paths="${1}" _paths="${1}"
shift -- 1 shift -- 1
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / client' \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${ZRUN[@]}" ':: tools / wrk' \ "${ZRUN[@]}" ':: tools / wrk' \
"${@}" \ "${@}" \
--script ../kawipiko-examples/sources/wrk-paths-from-file.lua \ --script ../kawipiko-examples/sources/wrk-paths-from-file.lua \
@ -569,14 +539,7 @@
_path='' _path=''
fi fi
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / client' \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${ZRUN[@]}" ':: tools / h1load' \ "${ZRUN[@]}" ':: tools / h1load' \
"${@}" \ "${@}" \
"${_url_base}/${_path}" \ "${_url_base}/${_path}" \
@ -614,14 +577,7 @@
_path='' _path=''
fi fi
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / client' \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${ZRUN[@]}" ':: tools / h2load' \ "${ZRUN[@]}" ':: tools / h2load' \
"${@}" \ "${@}" \
-- \ -- \
@ -656,14 +612,7 @@
_path='' _path=''
fi fi
exec -- \ exec -- \
nodaemon \ "${ZRUN[@]}" ':: benchmark / execute / client' \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${ZRUN[@]}" ':: tools / hey' \ "${ZRUN[@]}" ':: tools / hey' \
"${@}" \ "${@}" \
-- \ -- \
@ -671,3 +620,112 @@
# #
!! !!
--<< benchmark / execute / server
test "${#}" -ge 1
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )"
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / execute / server' "${@}"
fi
_wrapper=()
if test "${1}" == noenvironment ; then
_wrapper+=( env -i -- )
shift -- 1
test "${#}" -ge 1
fi
if test "${1}" == "${ZRUN_EXECUTABLE}" ; then
test "${#}" -ge 1
_command=( "${@:2}" )
else
_command=( "${@}" )
fi
printf -- '\n[xx] >> %s\n\n' "${_command[*]@Q}" >&2
exec -- \
sudo -u root -n -E -P -- \
taskset -c 0,1 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${_wrapper[@]}" \
"${@}" \
#
!!
--<< benchmark / execute / client
test "${#}" -ge 1
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )"
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / execute / client' "${@}"
fi
_wrapper=()
if test "${1}" == noenvironment ; then
_wrapper+=( env -i -- )
shift -- 1
test "${#}" -ge 1
fi
if test "${1}" == "${ZRUN_EXECUTABLE}" ; then
test "${#}" -ge 1
_command=( "${@:2}" )
else
_command=( "${@}" )
fi
printf -- '\n[xx] >> %s\n\n' "${_command[*]@Q}" >&2
exec -- \
sudo -u root -n -E -P -- \
taskset -c 2,3 \
nice -n -19 -- \
ionice -c 2 -n 0 -- \
chrt -r 10 \
prlimit -n262144 -- \
sudo -u "${USER}" -n -E -P -- \
"${_wrapper[@]}" \
"${@}" \
#
!!
--<< benchmark / execute / multiple
test "${#}" -ge 2
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )"
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / execute / multiple' "${@}"
fi
_count="$( printf -- '%d' "${1}" )"
shift -- 1
if test "${_count}" -le 1 ; then
exec -- "${@}"
fi
_pids=()
for (( _index = 1 ; _index <= _count ; _index += 1 )) ; do
( sleep -- "$(( _index - 1 ))s" || true ; exec -- "${@}" ) &
_pids+=( "${!}" )
done
(
trap 'kill -- "${_pids[@]}" 2> /dev/null || true' SIGINT SIGTERM SIGQUIT
if ! sleep -- "$(( _count ))s" ; then
kill -- "${_pids[@]}" 2> /dev/null || true
exit -- 0
fi
printf -- '\n[--]\n\n' >&2
while true ; do
if ! kill -s 0 -- "${_pids[@]}" 2> /dev/null ; then
break
fi
if ! sleep -- 6s ; then
break
fi
done
kill -- "${_pids[@]}" 2> /dev/null || true
) &
exit -- 0
!!

View file

@ -9,7 +9,6 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/wrk \ ./.bin/wrk \
--threads 1 \ --threads 1 \
--connections 1 \ --connections 1 \
@ -30,13 +29,13 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/h1load \ ./.bin/h1load \
-t 1 \ -t 1 \
-c 1 \ -c 1 \
-w 1000 \ -w 1000 \
-d 30 \ -d 30 \
-s 1 \ -s 1 \
-l \
"${@}" \ "${@}" \
# #
!! !!
@ -50,7 +49,6 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/h2load \ ./.bin/h2load \
--threads 1 \ --threads 1 \
--clients 1 \ --clients 1 \
@ -70,7 +68,6 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/hey \ ./.bin/hey \
-cpus 1 \ -cpus 1 \
-c 1 \ -c 1 \
@ -89,7 +86,6 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/nghttp \ ./.bin/nghttp \
--no-verify-peer \ --no-verify-peer \
"${@}" \ "${@}" \
@ -105,7 +101,6 @@
test "${#}" -ge 1 test "${#}" -ge 1
exec -- \ exec -- \
env -i -- \ env -i -- \
./.bin/nodaemon \
./.bin/curl \ ./.bin/curl \
--silent \ --silent \
--insecure \ --insecure \