Vecna 1 месяц назад
Родитель
Сommit
253db0f09e
3 измененных файлов с 45 добавлено и 24 удалено
  1. 1 0
      conf/Dockerfile
  2. 14 3
      run.sh
  3. 30 21
      scripts/generate-lox-results.sh

+ 1 - 0
conf/Dockerfile

@@ -2,6 +2,7 @@
 
 FROM rust:1.93.0
 RUN apt update -y && apt upgrade -y
+RUN apt install numactl
 WORKDIR /home/lox
 ADD crates/ ./crates/
 ADD Cargo.toml Cargo.toml

+ 14 - 3
run.sh

@@ -1,18 +1,29 @@
 #!/bin/bash
 
 fast=false
-ncpus=$(nproc)
+ncpus=""
+cpurange=""
 
-while -n "$1"; do
+while [ -n "$1" ]; do
     if [ "$1" == "--fast" ]; then
         fast=true
     elif [ "$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
+
 abort() {
     echo "Step $1 failed."
     echo "To restart from this step, try running:"
@@ -74,7 +85,7 @@ if [[ ! -d parsing-results/lox-old || ! -d parsing-results/lox-new || ! -d parsi
     # Clean up any remnants of previous attempts and try again
     rm -rf parsing-results/{lox-{old,new},troll-patrol}
 
-    ./scripts/generate-lox-results.sh -n "$ncpus" || abort "lox-gen"
+    ./scripts/generate-lox-results.sh -N "$cpurange" -n "$ncpus" || abort "lox-gen"
 fi
 
 # Process Lox benchmark results

+ 30 - 21
scripts/generate-lox-results.sh

@@ -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]}"