Skip to content

Commit 8ed3657

Browse files
DCperf mini: Shrinking feedsim mini execution time (#212)
Summary: Pull Request resolved: #212 Differential Revision: D81509229
1 parent 31c9bbb commit 8ed3657

4 files changed

Lines changed: 148 additions & 34 deletions

File tree

benchpress/config/jobs.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,19 @@
472472
- '-q {fixed_qps}'
473473
- '-d {fixed_qps_duration}'
474474
- '-w {warmup_time}'
475+
- '-r {qps_percentage_threshold}'
476+
- '-x {max_warmup_iterations}'
475477
- '-S {graph_store_path}'
476478
- '-L {graph_load_path}'
479+
- '-N'
477480
- '{extra_args}'
478481
vars:
479482
- 'num_instances=-1'
480-
- 'fixed_qps=100'
481-
- 'fixed_qps_duration=300'
482-
- 'warmup_time=120'
483+
- 'fixed_qps=100000'
484+
- 'fixed_qps_duration=10'
485+
- 'warmup_time=4'
486+
- 'qps_percentage_threshold=-1'
487+
- 'max_warmup_iterations=-1'
483488
- 'graph_store_path=default_do_not_store'
484489
- 'graph_load_path=default_do_not_load'
485490
- 'extra_args='
@@ -535,13 +540,20 @@
535540
- '-q {fixed_qps}'
536541
- '-d {fixed_qps_duration}'
537542
- '-w {warmup_time}'
543+
- '-r {qps_percentage_threshold}'
544+
- '-x {max_warmup_iterations}'
545+
- '-S {graph_store_path}'
546+
- '-L {graph_load_path}'
547+
- '-N'
538548
- '{extra_args}'
539549
vars:
540550
- 'num_instances=-1'
541551
- 'icache_iterations=400000'
542-
- 'fixed_qps=100'
543-
- 'fixed_qps_duration=300'
544-
- 'warmup_time=120'
552+
- 'fixed_qps=100000'
553+
- 'fixed_qps_duration=10'
554+
- 'warmup_time=4'
555+
- 'qps_percentage_threshold=-1'
556+
- 'max_warmup_iterations=-1'
545557
- 'graph_store_path=default_do_not_store'
546558
- 'graph_load_path=default_do_not_load'
547559
- 'extra_args='

packages/feedsim/run-feedsim-multi.sh

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
6-
76
BREPS_LFILE=/tmp/feedsim_log.txt
87
IS_FIXED_QPS=0
98
FIXQPS_SUFFIX=""
@@ -28,9 +27,6 @@ Usage: ${0##*/} [OPTION]...
2827
-h Display this help and exit
2928
-n Number of parallel instances to run. Default: $(( ( NCPU + 99 ) / 100 ))
3029
-i Number of icache iterations to use. Default: 1600000
31-
-S Store the generated graph to a file (requires a file path)
32-
-L Load a graph from a file instead of generating one (requires a file path)
33-
-I Enable timing instrumentation for graph operations (build, store, load)
3430
3531
Any remaining arguments are passed to run.sh
3632
@@ -40,10 +36,6 @@ EOF
4036
SCRIPT_NAME="$(basename "$0")"
4137
echo "${SCRIPT_NAME}: DCPERF_PERF_RECORD=${DCPERF_PERF_RECORD}"
4238

43-
# Initialize variables for graph storage and loading
44-
STORE_GRAPH=""
45-
LOAD_GRAPH=""
46-
INSTRUMENT_GRAPH=""
4739

4840
while [ $# -ne 0 ]; do
4941
case $1 in
@@ -55,15 +47,7 @@ while [ $# -ne 0 ]; do
5547
-i)
5648
NUM_ICACHE_ITERATIONS="$2"
5749
;;
58-
-S)
59-
STORE_GRAPH="-S $2"
60-
;;
61-
-L)
62-
LOAD_GRAPH="-L $2"
63-
;;
64-
-I)
65-
INSTRUMENT_GRAPH="-I"
66-
;;
50+
6751
-h|--help)
6852
show_help >&2
6953
exit 1
@@ -73,7 +57,7 @@ while [ $# -ne 0 ]; do
7357
esac
7458

7559
case $1 in
76-
-n|-i|-S|-L)
60+
-n|-i)
7761
if [ -z "$2" ]; then
7862
echo "Invalid option: '$1' requires an argument" 1>&2
7963
exit 1
@@ -129,10 +113,10 @@ echo > $BREPS_LFILE
129113
# shellcheck disable=SC2086
130114
for i in $(seq 1 ${NUM_INSTANCES}); do
131115
CORE_RANGE="$(get_cpu_range "${NUM_INSTANCES}" "$((i - 1))")"
132-
CMD="IS_AUTOSCALE_RUN=${NUM_INSTANCES} taskset --cpu-list ${CORE_RANGE} ${FEEDSIM_ROOT}/run.sh -p ${PORT} -i ${NUM_ICACHE_ITERATIONS} -o feedsim_results_${FIXQPS_SUFFIX}${i}.txt ${STORE_GRAPH} ${LOAD_GRAPH} ${INSTRUMENT_GRAPH} $*"
116+
CMD="IS_AUTOSCALE_RUN=${NUM_INSTANCES} taskset --cpu-list ${CORE_RANGE} ${FEEDSIM_ROOT}/run.sh -p ${PORT} -i ${NUM_ICACHE_ITERATIONS} -o feedsim_results_${FIXQPS_SUFFIX}${i}.txt $*"
133117
echo "$CMD" > "${FEEDSIM_LOG_PREFIX}${i}.log"
134118
# shellcheck disable=SC2068,SC2069
135-
IS_AUTOSCALE_RUN=${NUM_INSTANCES} stdbuf -i0 -o0 -e0 taskset --cpu-list "${CORE_RANGE}" "${FEEDSIM_ROOT}"/run.sh -p "${PORT}" -i "${NUM_ICACHE_ITERATIONS}" -o "feedsim_results_${FIXQPS_SUFFIX}${i}.txt" ${STORE_GRAPH} ${LOAD_GRAPH} ${INSTRUMENT_GRAPH} $@ 2>&1 > "${FEEDSIM_LOG_PREFIX}${i}.log" &
119+
IS_AUTOSCALE_RUN=${NUM_INSTANCES} stdbuf -i0 -o0 -e0 taskset --cpu-list "${CORE_RANGE}" "${FEEDSIM_ROOT}"/run.sh -p "${PORT}" -i "${NUM_ICACHE_ITERATIONS}" -o "feedsim_results_${FIXQPS_SUFFIX}${i}.txt" $@ 2>&1 > "${FEEDSIM_LOG_PREFIX}${i}.log" &
136120
PIDS+=("$!")
137121
PHY_CORE_ID=$((PHY_CORE_ID + CORES_PER_INST))
138122
SMT_ID=$((SMT_ID + CORES_PER_INST))

packages/feedsim/run.sh

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ Usage: ${0##*/} [OPTION]...
6868
-S Store the generated graph to a file (requires a file path)
6969
-L Load a graph from a file instead of generating one (requires a file path)
7070
-I Enable timing instrumentation for graph operations (build, store, load)
71+
-r QPS increase threshold for steady state detection during warmup (in percentage). If specified and greater than zero, warmup continues until
72+
QPS increase is less than this threshold percentage of the previous QPS.
73+
-x Maximum number of warmup iterations when using QPS threshold. Default: 10
74+
-N No retry mode. Skip sleep and PID checking in load test startup, break immediately without retrying.
7175
EOF
7276
}
7377

@@ -135,6 +139,14 @@ main() {
135139
local instrument_graph
136140
instrument_graph=""
137141

142+
local qps_threshold
143+
qps_threshold=""
144+
145+
local max_warmup_iterations
146+
max_warmup_iterations="10"
147+
148+
local no_retry_mode
149+
no_retry_mode=""
138150

139151
if [ -z "$IS_AUTOSCALE_RUN" ]; then
140152
echo > $BREPS_LFILE
@@ -189,6 +201,19 @@ main() {
189201
-I)
190202
instrument_graph="--instrument_graph"
191203
;;
204+
-r)
205+
if [[ "$2" -gt 0 ]]; then
206+
qps_threshold="$2"
207+
fi
208+
;;
209+
-x)
210+
if [[ "$2" -gt 0 ]]; then
211+
max_warmup_iterations="$2"
212+
fi
213+
;;
214+
-N)
215+
no_retry_mode="1"
216+
;;
192217
-h|--help)
193218
show_help >&2
194219
exit 1
@@ -199,7 +224,7 @@ main() {
199224
esac
200225

201226
case $1 in
202-
-t|-c|-s|-d|-p|-q|-o|-w|-i|-l|-S|-L)
227+
-t|-c|-s|-d|-p|-q|-o|-w|-i|-l|-S|-L|-r|-x)
203228
if [ -z "$2" ]; then
204229
echo "Invalid option: '$1' requires an argument" 1>&2
205230
exit 1
@@ -268,9 +293,23 @@ main() {
268293

269294
# Start DriverNode
270295
client_monitor_port="$((monitor_port-1000))"
296+
297+
# Construct QPS threshold and max iterations parameters if specified
298+
qps_threshold_args=""
299+
if [ -n "$qps_threshold" ]; then
300+
qps_threshold_args="-r $qps_threshold -x $max_warmup_iterations"
301+
fi
302+
303+
# Construct no retry mode parameter if specified
304+
no_retry_args=""
305+
if [ -n "$no_retry_mode" ]; then
306+
no_retry_args="-N"
307+
fi
308+
271309
if [ -z "$fixed_qps" ] && [ "$auto_driver_threads" != "1" ]; then
272310
benchreps_tell_state "before search_qps"
273-
scripts/search_qps.sh -w 15 -f 300 -s 95p:500 -o "${FEEDSIM_ROOT}/${result_filename}" -- \
311+
# shellcheck disable=SC2086
312+
scripts/search_qps.sh -w 15 -f 300 -s 95p:500 $qps_threshold_args $no_retry_args -o "${FEEDSIM_ROOT}/${result_filename}" -- \
274313
build/workloads/ranking/DriverNodeRank \
275314
--server "0.0.0.0:$port" \
276315
--monitor_port "$client_monitor_port" \
@@ -279,7 +318,8 @@ main() {
279318
benchreps_tell_state "after search_qps"
280319
elif [ -z "$fixed_qps" ] && [ "$auto_driver_threads" = "1" ]; then
281320
benchreps_tell_state "before search_qps"
282-
scripts/search_qps.sh -a -w 15 -f 300 -s 95p:500 -o "${FEEDSIM_ROOT}/${result_filename}" -- \
321+
# shellcheck disable=SC2086
322+
scripts/search_qps.sh -a -w 15 -f 300 -s 95p:500 $qps_threshold_args $no_retry_args -o "${FEEDSIM_ROOT}/${result_filename}" -- \
283323
build/workloads/ranking/DriverNodeRank \
284324
--monitor_port "$client_monitor_port" \
285325
--server "0.0.0.0:$port"
@@ -296,9 +336,11 @@ main() {
296336
num_workers=$driver_threads
297337
fi
298338
benchreps_tell_state "before fixed_qps_exp"
339+
# shellcheck disable=SC2086
299340
scripts/search_qps.sh -s 95p -t "$fixed_qps_duration" \
300341
-m "$warmup_time" \
301342
-q "$fixed_qps" \
343+
$qps_threshold_args $no_retry_args \
302344
-o "${FEEDSIM_ROOT}/${result_filename}" \
303345
-- build/workloads/ranking/DriverNodeRank \
304346
--server "0.0.0.0:$port" \

packages/feedsim/third_party/src/scripts/search_qps.sh

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ mutilate (EuroSys \'14) [https://github.com/leverich/mutilate]
7777
appending '--threads=T --connections=4' to the driver command during load
7878
tests. T will be the lesser of requested_qps / 4 or $(nproc) / 5.
7979
-o output filename to record samples as csv. Optional
80+
-r QPS increase threshold for steady state detection during warmup (in percentage).
81+
When specified, warmup continues until QPS increase is less than this threshold
82+
percentage of the previous QPS. Optional
83+
-x Maximum number of warmup iterations when using QPS threshold. Default: 10
84+
-N No retry mode. Skip sleep and PID checking in load test startup, break immediately
85+
without retrying. Optional
8086
EOF
8187
}
8288

@@ -122,19 +128,28 @@ run_loadtest() {
122128
local tmp_file=$(mktemp)
123129
$command $threads_arg $qps_arg &>$tmp_file &
124130
LOADTEST_PID=$!
125-
sleep 7
126-
ps -p $LOADTEST_PID -o pid= > /dev/null && break
127-
echo "Retrying $r of 3 to start load test..."
131+
132+
if [ "$no_retry_mode" = "1" ]; then
133+
# No retry mode: skip sleep and PID checking, break immediately
134+
break
135+
else
136+
# Normal mode: sleep and check PID
137+
sleep 7
138+
ps -p $LOADTEST_PID -o pid= > /dev/null && break
139+
benchreps_tell_state "Retrying $r of 3 to start load test..."
140+
fi
128141
done
129142

130143
# wait for time
131144
sleep $experiment_time
145+
benchreps_tell_state "after sleeping for experiment_time=${experiment_time} seconds"
132146

133147
# send SIGINT to the command
134148
kill -SIGINT $LOADTEST_PID
135149

136150
# wait for results to show up and queries to drain
137151
sleep $wait_time
152+
benchreps_tell_state "after sleeping for wait_time=${wait_time} seconds"
138153

139154
# check file for QPS
140155
if grep -q "#: [0-9]\+.\([0-9]\+\)\? QPS" $tmp_file; then
@@ -216,9 +231,12 @@ load_test_retries=3
216231
output_csv_file=""
217232
fixed_qps=""
218233
auto_driver_threads=""
234+
qps_threshold=""
235+
max_warmup_iterations=10
236+
no_retry_mode=""
219237

220238
OPTIND=1 # Reset is necessary if getopts was used previously in the script. It is a good idea to make this local in a function.
221-
while getopts "ht:f:w:m:s:q:ao:" opt; do
239+
while getopts "ht:f:w:m:s:q:ao:r:x:N" opt; do
222240
case "$opt" in
223241
h)
224242
show_help
@@ -249,6 +267,15 @@ while getopts "ht:f:w:m:s:q:ao:" opt; do
249267
o)
250268
output_csv_file=$OPTARG
251269
;;
270+
r)
271+
qps_threshold=$OPTARG
272+
;;
273+
x)
274+
max_warmup_iterations=$OPTARG
275+
;;
276+
N)
277+
no_retry_mode=1
278+
;;
252279
'?')
253280
show_help >&2
254281
exit 1
@@ -322,8 +349,54 @@ if [ "$warmup_time" -gt 0 ]; then
322349
benchreps_tell_state "before warmup"
323350
saved_experiment_time="$experiment_time"
324351
experiment_time="$warmup_time"
325-
run_loadtest peak_qps measured_latency
352+
353+
if [ -n "$qps_threshold" ]; then
354+
# Dynamic QPS-based warmup
355+
previous_qps=0
356+
warmup_iteration=0
357+
358+
while [ $warmup_iteration -lt $max_warmup_iterations ]; do
359+
run_loadtest current_qps measured_latency
360+
benchreps_tell_state "after iteration $warmup_iteration"
361+
printf "warmup iteration %d: qps = %.2f, latency = %.2f\n" $warmup_iteration $current_qps $measured_latency >> $BREPS_LFILE
362+
363+
# Skip first warmup iteration, always do the second round
364+
if [ $warmup_iteration -gt 1 ]; then
365+
# Calculate percentage increase: (current - previous) / previous * 100
366+
if [ $(echo "$previous_qps > 0" | bc) -eq 1 ]; then
367+
qps_increase_percentage=$(echo "scale=5; ($current_qps - $previous_qps) / $previous_qps * 100" | bc)
368+
# Convert to absolute value for comparison
369+
#qps_increase_abs=$(echo "scale=5; ($qps_increase_percentage^2)^0.5" | bc)
370+
#qps_increase_check=$(echo "$qps_increase_abs <= $qps_threshold" | bc)
371+
qps_increase_check=$(echo "$qps_increase_percentage <= $qps_threshold" | bc)
372+
373+
if [ $qps_increase_check -eq 1 ]; then
374+
printf "QPS steady state reached. QPS increase percentage (%.2f%%) is less than threshold (%.2f%%)\n" $qps_increase_percentage $qps_threshold >> $BREPS_LFILE
375+
break
376+
fi
377+
else
378+
# If previous_qps is 0, skip the check for this iteration
379+
printf "Previous QPS is 0, skipping threshold check for iteration %d\n" $warmup_iteration >> $BREPS_LFILE
380+
fi
381+
fi
382+
383+
previous_qps=$current_qps
384+
warmup_iteration=$((warmup_iteration + 1))
385+
386+
# Wait between warmup iterations (except for the last one)
387+
if [ $warmup_iteration -lt $max_warmup_iterations ]; then
388+
sleep $wait_time
389+
fi
390+
done
391+
392+
peak_qps=$current_qps
393+
else
394+
# Original fixed warmup time
395+
run_loadtest peak_qps measured_latency
396+
fi
397+
326398
printf "warmup qps = %.2f, latency = %.2f\n" $peak_qps $measured_latency
399+
echo "warmup qps = $peak_qps, latency = $measured_latency" >> $BREPS_LFILE
327400
benchreps_tell_state "after warmup"
328401
experiment_time="$saved_experiment_time"
329402
fi
@@ -338,13 +411,16 @@ if [[ -n "$fixed_qps" ]]; then
338411
collect_perf_record &
339412
fi
340413
run_loadtest measured_qps measured_latency $fixed_qps
414+
341415
printf "final requested_qps = %.2f, measured_qps = %.2f, latency = %.2f\n" $fixed_qps $measured_qps $measured_latency
416+
echo "final requested_qps = $fixed_qps, measured_qps = $measured_qps, latency = $measured_latency" >> $BREPS_LFILE
342417
benchreps_tell_state "after fixed_qps_single"
343418
else
344419
for fixed_qps_el in $fixed_qps_array; do
345420
benchreps_tell_state "before fixed_qps_iter $fixed_qps_el"
346421
run_loadtest measured_qps measured_latency $fixed_qps_el
347422
printf "final requested_qps = %.2f, measured_qps = %.2f, latency = %.2f\n" $fixed_qps_el $measured_qps $measured_latency
423+
echo "final requested_qps = $fixed_qps_el, measured_qps = $measured_qps, latency = $measured_latency" >> $BREPS_LFILE
348424
benchreps_tell_state "after fixed_qps_iter $fixed_qps_el"
349425
sleep 7 # wait between iterations
350426
done

0 commit comments

Comments
 (0)