Skip to content

Commit

Permalink
Add cpu-limit option for mini-benchmark
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tonychen2001 authored and ottok committed Apr 7, 2024
1 parent af4df93 commit 2b0e073
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions support-files/mini-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2b0e073

Please sign in to comment.