[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;
worker_processes 2;
master_process off;
worker_processes 0;
worker_rlimit_nofile 131072;
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 / 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 / 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 / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server / inmem' http-go "${@}" --processes 2 --threads 1
@ -252,15 +250,8 @@
;;
esac
exec -- \
nodaemon \
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 -- \
env -i -- \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.outputs/binaries/release/kawipiko-server \
"${_arguments[@]}" \
--archive "${_archive}" \
@ -309,12 +300,22 @@
<< benchmark / server / profile / cpu / analyze
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
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
@ -325,12 +326,22 @@
<< benchmark / server / profile / mem / analyze
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
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
@ -341,24 +352,24 @@
:: benchmark / dummy / fasthttp / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 "${@}"
:: benchmark / dummy / fasthttp / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 "${@}"
:: benchmark / dummy / fasthttp / 1x4 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 4 "${@}"
:: benchmark / dummy / fasthttp / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 1 "${@}"
:: benchmark / dummy / fasthttp / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 2 "${@}"
:: 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
"${ZRUN[@]}" ':: go / build / server-dummy / release / quick'
test "${#}" -ge 2
_count="${1}"
_threads="${2}"
shift -- 2
exec -- \
nodaemon \
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 -- \
env -i -- \
"${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.outputs/binaries/release/kawipiko-server-dummy \
"127.9.185.194:8080" \
"${_threads}" \
"${@}" \
#
!!
@ -366,15 +377,8 @@
<< benchmark / dummy / haproxy / 1x2
exec -- \
nodaemon \
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 -- \
env -i -- \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.bin/haproxy \
-db \
-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 -- \
nodaemon \
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 -- \
env -i -- \
"${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.bin/nginx \
-c ./examples/dummy/nginx-dummy.conf \
-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 -- \
nodaemon \
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 -- \
env -i -- \
"${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.bin/node16 \
-- \
./examples/dummy/nodejs-dummy.js \
@ -423,36 +426,17 @@
!!
<< benchmark / dummy / httpterm / 2x1
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )"
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 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / httpterm' 1 "${@}"
:: benchmark / dummy / httpterm / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / httpterm' 2 "${@}"
<< benchmark / dummy / httpterm / 1x1
_nodaemon="$( exec -- readlink -e -- "$( type -P -- nodaemon )" )"
if test ! "/proc/${PPID}/exe" -ef "${_nodaemon}" ; then
exec -- nodaemon "${ZRUN[@]}" ':: benchmark / dummy / httpterm / 1x1' "${@}"
fi
--<< benchmark / dummy / httpterm
test "${#}" -ge 1
_count="${1}"
shift -- 1
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 -- \
env -i \
"${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \
"${ZRUN[@]}" ':: benchmark / execute / server' \
noenvironment \
./.bin/httpterm \
-db \
-L 127.9.185.194:8080 \
@ -491,14 +475,7 @@
_path=''
fi
exec -- \
nodaemon \
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[@]}" ':: benchmark / execute / client' \
"${ZRUN[@]}" ':: tools / wrk' \
"${@}" \
-- \
@ -525,14 +502,7 @@
_paths="${1}"
shift -- 1
exec -- \
nodaemon \
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[@]}" ':: benchmark / execute / client' \
"${ZRUN[@]}" ':: tools / wrk' \
"${@}" \
--script ../kawipiko-examples/sources/wrk-paths-from-file.lua \
@ -569,14 +539,7 @@
_path=''
fi
exec -- \
nodaemon \
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[@]}" ':: benchmark / execute / client' \
"${ZRUN[@]}" ':: tools / h1load' \
"${@}" \
"${_url_base}/${_path}" \
@ -614,14 +577,7 @@
_path=''
fi
exec -- \
nodaemon \
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[@]}" ':: benchmark / execute / client' \
"${ZRUN[@]}" ':: tools / h2load' \
"${@}" \
-- \
@ -656,14 +612,7 @@
_path=''
fi
exec -- \
nodaemon \
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[@]}" ':: benchmark / execute / client' \
"${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
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/wrk \
--threads 1 \
--connections 1 \
@ -30,13 +29,13 @@
test "${#}" -ge 1
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/h1load \
-t 1 \
-c 1 \
-w 1000 \
-d 30 \
-s 1 \
-l \
"${@}" \
#
!!
@ -50,7 +49,6 @@
test "${#}" -ge 1
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/h2load \
--threads 1 \
--clients 1 \
@ -70,7 +68,6 @@
test "${#}" -ge 1
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/hey \
-cpus 1 \
-c 1 \
@ -89,7 +86,6 @@
test "${#}" -ge 1
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/nghttp \
--no-verify-peer \
"${@}" \
@ -105,7 +101,6 @@
test "${#}" -ge 1
exec -- \
env -i -- \
./.bin/nodaemon \
./.bin/curl \
--silent \
--insecure \