Skip to content

Commit

Permalink
test: update src/test/sched-bench.sh
Browse files Browse the repository at this point in the history
Fix the sched-bench.sh script to work with modern flux-core.

Add new -v, --verbose and -o, --sched-opts=OPTS options, and change
-n for --nnodes to -N to avoid confusion with other flux commands.
  • Loading branch information
grondo authored and mergify-bot committed Feb 12, 2020
1 parent 0d345a0 commit 7b7c537
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/test/sched-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@ declare prog=$(basename $0)
declare NNODES=8
declare CPN=32

declare -r long_opts="help,nnodes:,cores-per-node:,jobs:,noexec"
declare -r short_opts="hn:c:j:"
declare -r long_opts="help,nnodes:,cores-per-node:,jobs:,noexec,sched-opts:verbose"
declare -r short_opts="hvN:c:j:o:"
declare -r usage="\
\n\
Usage: $prog [OPTIONS]\n\
Simple Flux sched/exec test benchmark.\n\
\n\
Options:\n\
-h, --help display this messages\n\
-n, --nnodes=NNODES set simulated number of nodes (default=${NNODES})\n\
-v, --verbose run with extra verbose output\n\
-N, --nnodes=NNODES set simulated number of nodes (default=${NNODES})\n\
-c, --cores-per-node=N set simulated cores per node (default=${CPN})\n\
-j, --jobs=NJOBS set number of jobs to run (default nnodes*cpn)\n\
-o, --sched-opts=OPTS set scheduler module load options\n\
--noexec do not simulate execution, just scheduling\n"


log() { local fmt=$1; shift; printf >&2 "$prog: $fmt" "$@"; }
die() { log "$@" && exit 1; }

verbose() { test $VERBOSE = "t" && log "$@"; }

log_timing_msg() {
local name=$1
local start=$2
Expand All @@ -43,9 +48,11 @@ fi
eval set -- "$GETOPTS"
while true; do
case "$1" in
-n|--nnodes) NNODES=$2; shift 2 ;;
-v|--verbose) VERBOSE=t; shift ;;
-N|--nnodes) NNODES=$2; shift 2 ;;
-c|--cores-per-node) CPN=$2; shift 2 ;;
-j|--jobs) NJOBS=$2; shift 2 ;;
-o|--sched-opts) OPTS="$2"; shift 2 ;;
--noexec) NOEXEC=t; shift ;;
--) shift ; break ; ;;
-h|--help) echo -e "$usage" ; exit 0 ;;
Expand All @@ -64,32 +71,40 @@ log "broker.pid=$(flux getattr broker.pid)\n"
flux module remove sched-simple
flux kvs put --json \
resource.hwloc.by_rank="{\"[0-$(($NNODES-1))]\":{\"Core\":$CPN}}"
flux jobspec srun hostname | jq '.attributes.system.duration = .0001' > job.json
flux module load sched-simple
flux mini run --dry-run --setattr=system.exec.test.run_duration=.001s hostname \
> job.json

log "Loading sched-simple: ${OPTS}\n"
flux module load sched-simple ${OPTS} || die "Failed to load sched-simple"

# If not testing exec system, remove the job-exec module
test "$NOEXEC" = "t" && flux module remove job-exec

t_start=$(date +%s.%N)
t/ingest/submitbench -f 24 -r $NJOBS job.json > job.list
t/ingest/submitbench -f 1024 -r $NJOBS job.json > job.list
t_ingest=$(date +%s.%N)
log_timing_msg ingested $t_start $t_ingest

first=$(flux job list -s -c 1 | awk '{print $1}')
last=$(flux job list -s | tail -1 | awk '{print $1}')
test "$VERBOSE" = "t" && flux queue status -v

last=$(tail -1 job.list)
first=$(head -1 job.list)

starttime=$(flux job eventlog $first | awk '$2 == "submit" {print $1}')
alloctime=$(flux job wait-event $last alloc | awk '$2 == "alloc" {print $1}')
log_timing_msg allocated $starttime $alloctime

test "$VERBOSE" = "t" && flux queue status -v

if test -z "$NOEXEC"; then
runtime=$(flux job wait-event $last clean | awk '{print $1}')
log_timing_msg ran $starttime $runtime
fi

flux queue drain
flux job cancelall -f
flux queue idle --quiet

flux job eventlog $last
test "$VERBOSE" = "t" && flux queue status -v

t_done=$(date +%s.%N)
log_timing_msg "total walltime for" $t_start $t_done
Expand Down

0 comments on commit 7b7c537

Please sign in to comment.