Commit 2b0e0730 authored by Tony Chen's avatar Tony Chen Committed by Otto Kekäläinen

Add cpu-limit option for mini-benchmark

As performance improves, the permitted number of CPU cycles to be used
during the benchmark should be lowered to catch performance regressions. An
option is added to better support this.

All new code of the whole pull request, including one or several files that are
either new files or modified ones, are contributed under the BSD-new license. I
am contributing on behalf of my employer Amazon Web Services, Inc.
parent af4df93c
......@@ -26,6 +26,8 @@ display_help() {
echo " sysbench runs"
echo " --perf-flamegraph record performance counters in perf.data.* and"
echo " generate flamegraphs automatically"
echo " --cpu-limit upper limit on the number of CPU cycles (in billions) used for the benchmark"
echo " default: 750"
echo " -h, --help display this help and exit"
}
......@@ -79,6 +81,11 @@ do
PERF_RECORD=true
shift
;;
--cpu-limit)
shift
CPU_CYCLE_LIMIT=$1
shift
;;
-*)
echo "Error: Unknown option: $1" >&2
## or call function display_help
......@@ -247,12 +254,21 @@ then
echo "Total: $(grep -h -e instructions sysbench-run-*.log | sort -k 1 | awk '{s+=$1}END{print s}')"
echo # Newline improves readability
if [ -z "$CPU_CYCLE_LIMIT" ]
then
# 04-04-2024: We found this to be an appropriate default limit after running a few benchmarks
# Configure the limit with --cpu-limit if needed
CPU_CYCLE_LIMIT=750
fi
CPU_CYCLE_LIMIT_LONG="${CPU_CYCLE_LIMIT}000000000"
# Final verdict based on cpu cycle count
RESULT="$(grep -h -e cycles sysbench-run-*.log | sort -k 1 | awk '{s+=$1}END{print s}')"
if [ "$RESULT" -gt 850 ]
if [ "$RESULT" -gt "$CPU_CYCLE_LIMIT_LONG" ]
then
echo # Newline improves readability
echo "Benchmark exceeded 850 billion cpu cycles, performance most likely regressed!"
echo "Benchmark exceeded the allowed limit of ${CPU_CYCLE_LIMIT} billion CPU cycles"
echo "Performance most likely regressed!"
exit 1
fi
fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment