generate-lox-results.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. ncpus=""
  3. cpurange=""
  4. while [ -n "$1" ]; do
  5. if [ "$1" == "-n" ]; then
  6. ncpus="$2"
  7. shift
  8. elif [ "$1" == "-N" ]; then
  9. cpurange="$2"
  10. shift
  11. fi
  12. shift
  13. done
  14. if [ -z "$ncpus" ]; then
  15. if [ -n "$cpurange" ]; then
  16. ncpus=$(docker run --rm troll-patrol numactl -C $cpurange nproc)
  17. else
  18. ncpus=$(nproc)
  19. fi
  20. fi
  21. if [ -z "$cpurange" ]; then
  22. cpurange="0-$((ncpus - 1))"
  23. fi
  24. hosts=()
  25. for i in {1..5}; do
  26. hosts+=(lox-old)
  27. done
  28. for i in {1..5}; do
  29. hosts+=(lox-new)
  30. done
  31. for i in {1..6}; do
  32. hosts+=(troll-patrol)
  33. done
  34. cmds=(
  35. "cargo test --release --features fast -- --nocapture stats_test_trust_levels > trust_levels.log"
  36. "cargo test --release --features fast -- --nocapture stats_test_invitations > invitations.log"
  37. "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log"
  38. "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log"
  39. "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log"
  40. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_trust_levels > trust_levels.log"
  41. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_invitations > invitations.log"
  42. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log"
  43. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log"
  44. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log"
  45. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_reporting > reporting.log"
  46. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_trust_levels > trust_levels.log"
  47. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_invitations > invitations.log"
  48. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log"
  49. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log"
  50. "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log"
  51. )
  52. index=0
  53. i=0
  54. for i in ${!cmds[@]}; do
  55. cmd="${cmds[$i]}"
  56. file="${cmd##* }"
  57. host="${hosts[$i]}"
  58. echo "Starting command ${cmd} with docker image ${host} with index ${index}..."
  59. # New container
  60. docker run --name "${host}-${file}" --rm -d -i "${host}:latest" || exit 1
  61. # Run command in this docker
  62. docker exec "${host}-${file}" numactl -C "$cpurange" numactl -C +$index sh -c "$cmd" &
  63. index=$((index + 1))
  64. echo "Command started and pushed to background."
  65. if [ $index == "$ncpus" ]; then
  66. echo "Waiting for the first $ncpus commands to complete..."
  67. wait
  68. index=0
  69. fi
  70. done
  71. wait
  72. # Extract log files from docker containers and shut them down
  73. mkdir -p parsing-results/{lox-old,lox-new,troll-patrol}
  74. for i in {0..4}; do
  75. cmd="${cmds[$i]}"
  76. file="${cmd##* }"
  77. host="${hosts[$i]}"
  78. docker cp "${host}-${file}":/home/lox/"${file}" parsing-results/lox-old/ && docker stop "${host}-${file}"
  79. done
  80. for i in {5..15}; do
  81. cmd="${cmds[$i]}"
  82. file="${cmd##* }"
  83. host="${hosts[$i]}"
  84. docker cp "${host}-${file}":/home/lox/crates/lox-extensions/"${file}" parsing-results/${host}/ && docker stop "${host}-${file}"
  85. done