-
Notifications
You must be signed in to change notification settings - Fork 2
/
benchmark_docker.sh
executable file
·50 lines (44 loc) · 3.25 KB
/
benchmark_docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# \description Starts benchmarking from the docker container environment
#
# The benchmarking is started under the current user on the current host
# directory, which is bound to the docker container directory.
# The specified arguments are passed to the benchmarking being run in the container.
#
# \author Artem V L <[email protected]>
# Notes:
# - $@ - are the input arguments passed to the benchmark started from the container
# - $UID or `id -u $USER` - user id of the current user, otherwise 'root' is used.
# $UID might not be defined in "sh"
echo "Ensuring the required host environment..."
CALLDIR=`dirname $0` # Calling directory (base path) of this script
CALLDIR=`readlink -f ${CALLDIR}` # Conver path to the absolute canonical path (docker requires the absolute path)
${CALLDIR}/prepare_hostenv.sh
echo "Starting docker from \"`pwd`\" under user \"$USER\" with the benchmark arguments: $@"
WORK_DIR=/opt/clubmark # Working directory of the benchmark inside the Docker container (may not exist on the host)
# Notes:
# - quoted $@ is required to retain internal quotation inside the arguments
# - python3 is used to run the benchmark instead of pypy to reduce the number of
# dependencies, because otherwise Python is also required to install the psutil
# via pip on pypy
# Bind Docker :8080 to the host :80 for tcp. To bind with specific host IP: -p IP:8080:80/tcp
# -rm is used to automaticaly clean up the executed container and remove the virtual file system on exit
# Only one instance of the benchmark is supposed to be run on the server, so the explicit container name can be set for readibility
# Log direr can be set to `none` instead of the default `json-file` because anyway it contains stdout + stderr and is redirected to the file(s)
# NOTE: docker outputs both stdout and stderr of the executing app from it's stdout
docker run --name clubmark --log-driver=none -it --rm -p 8080:8080/tcp -u `id -u $USER` -w ${WORK_DIR} -v ${CALLDIR}:${WORK_DIR} --entrypoint python3 luaxi/clubmark-env:v3.0-U16.04 ./benchmark.py "$@"
# Outdated: docker run -it -u `id -u $USER` -w ${WORK_DIR} -v `pwd`:${WORK_DIR} --entrypoint python3 luaxi/pycabem:env-U16.04-v2.0 ./benchmark.py "$@"
# Or to open "bash" shell in the benchmarking directory:
# $ docker run -it -u `id -u $USER` -w ${WORK_DIR} -v `pwd`:${WORK_DIR} --entrypoint bash luaxi/clubmark-env:v3.0-U16.04
# Examples:
# $ ./benchmark_docker.sh -a="LouvainIg Randcommuns" -i="syntnets/networks/*/" -i=./realnets -r -th=42 1>>./results/bench.log 2>>./results/bench.err
# $ ./benchmark_docker.sh -a="LouvainIg Scp Randcommuns Pscan" -i%2=./realnets -r -th=42 1>> ./results/bench.log 2>> ./results/bench.err
# $ ./benchmark_docker.sh -w=0.0.0.0:8080 -a="CggcRg CggciRg LouvainIg Oslom2 Pscan Randcommuns Scd Scp" -r -t=36h --runtimeout=12d 1>> ./results/bench.log 2>> ./results/bench.err
# $ ./benchmark_docker.sh -w=0.0.0.0:8080 -g=3%5 -a="CggcRg CggciRg LouvainIg Oslom2 Pscan Randcommuns Scd Scp" -r -t=36h --runtimeout=12d 1>> ./results/bench.log 2>> ./results/bench.err
# Note: to redirect host:80 to :8080, where the benchmark WebUI is run:
# # iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
# To check redirection:
# # iptables -t nat --line-numbers -n -L
# To remove redirection:
# iptables -t nat -D PREROUTING 2