|
|
@@ -1,18 +1,34 @@
|
|
|
#!/bin/bash
|
|
|
|
|
|
-ncpus=$(nproc)
|
|
|
-if [ "$1" == "-n" ]; then
|
|
|
- ncpus="$2"
|
|
|
+ncpus=""
|
|
|
+cpurange=""
|
|
|
+
|
|
|
+while [ -n "$1" ]; do
|
|
|
+ if [ "$1" == "-n" ]; then
|
|
|
+ ncpus="$2"
|
|
|
+ shift
|
|
|
+ elif [ "$1" == "-N" ]; then
|
|
|
+ cpurange="$2"
|
|
|
+ shift
|
|
|
+ fi
|
|
|
+ shift
|
|
|
+done
|
|
|
+
|
|
|
+if [ -z "$ncpus" ]; then
|
|
|
+ ncpus=$(nproc)
|
|
|
+fi
|
|
|
+if [ -z "$cpurange" ]; then
|
|
|
+ cpurange="0-$((ncpus - 1))"
|
|
|
fi
|
|
|
|
|
|
hosts=()
|
|
|
-for i in $(seq 1 5); do
|
|
|
+for i in {1..5}; do
|
|
|
hosts+=(lox-old)
|
|
|
done
|
|
|
-for i in $(seq 1 5); do
|
|
|
+for i in ${1..5}; do
|
|
|
hosts+=(lox-new)
|
|
|
done
|
|
|
-for i in $(seq 1 6); do
|
|
|
+for i in ${1..6}; do
|
|
|
hosts+=(troll-patrol)
|
|
|
done
|
|
|
|
|
|
@@ -38,25 +54,18 @@ cmds=(
|
|
|
index=0
|
|
|
i=0
|
|
|
|
|
|
-for i in $(seq 0 15); do
|
|
|
+for i in ${!cmds[@]}; do
|
|
|
cmd="${cmds[$i]}"
|
|
|
file="${cmd##* }"
|
|
|
host="${hosts[$i]}"
|
|
|
|
|
|
echo "Starting command ${cmd} with docker image ${host} with index ${index}..."
|
|
|
|
|
|
- if command -v numactl > /dev/null; then
|
|
|
- # New container isolated to one CPU
|
|
|
- numactl -C $index docker run --name "${host}-${file}" --rm -d -i "${host}:latest" || exit 1
|
|
|
- # Run command in this docker
|
|
|
- numactl -C $index docker exec "${host}-${file}" sh -c "$cmd" &
|
|
|
- else
|
|
|
- echo "numactl is not installed; not isolating each command to one CPU"
|
|
|
- # New container
|
|
|
- docker run --name "${host}-${file}" --rm -d -i "${host}:latest" || exit 1
|
|
|
- # Run command in this docker
|
|
|
- docker exec "${host}-${file}" sh -c "$cmd" &
|
|
|
- fi
|
|
|
+ # New container
|
|
|
+ docker run --name "${host}-${file}" --rm -d -i "${host}:latest" || exit 1
|
|
|
+ # Run command in this docker
|
|
|
+ docker exec "${host}-${file}" numactl -C "$cpurange" numactl -C +$index sh -c "$cmd" &
|
|
|
+
|
|
|
index=$((index + 1))
|
|
|
echo "Command started and pushed to background."
|
|
|
|
|
|
@@ -70,14 +79,14 @@ wait
|
|
|
|
|
|
# Extract log files from docker containers and shut them down
|
|
|
mkdir -p parsing-results/{lox-old,lox-new,troll-patrol}
|
|
|
-for i in $(seq 0 4); do
|
|
|
+for i in ${0..4}; do
|
|
|
cmd="${cmds[$i]}"
|
|
|
file="${cmd##* }"
|
|
|
host="${hosts[$i]}"
|
|
|
|
|
|
docker cp "${host}-${file}":/home/lox/"${file}" parsing-results/lox-old/ && docker stop "${host}-${file}"
|
|
|
done
|
|
|
-for i in $(seq 5 15); do
|
|
|
+for i in ${5..15}; do
|
|
|
cmd="${cmds[$i]}"
|
|
|
file="${cmd##* }"
|
|
|
host="${hosts[$i]}"
|