Skip to content

Commit bc01bcb

Browse files
committed
Skip the first value for regression check
This commit adds changes to the check_regression.sh script to skip the first benchmark times in both the old and new benchmark results and check for regression in the newly calculated p90, this is to combat the skewed reults in the benchmark results due to the variability in github runners. It also moves the threshold limit to 150% Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent a3fdb6b commit bc01bcb

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

.github/workflows/benchmark_regression_test.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- '.github/workflows/**'
1515

1616
jobs:
17-
test-twice:
17+
run_benchmark_twice:
1818
runs-on: ubuntu-20.04
1919

2020
steps:
@@ -52,16 +52,18 @@ jobs:
5252

5353
download_and_perform_comparison:
5454
runs-on: ubuntu-20.04
55-
needs: test-twice
55+
needs: run_benchmark_twice
5656
steps:
5757
- uses: actions/setup-go@v4
5858
with:
5959
go-version: '1.18.10'
6060
- name: Checkout main
6161
uses: actions/checkout@v3
6262
with:
63-
ref: main
63+
ref: ${{ github.event.pull_request.head.sha }}
6464
- run: make
65+
- name: Install basic calculator
66+
run: sudo apt-get install bc
6567

6668
- name: Create previous directory
6769
run: mkdir -v ${{ github.workspace }}/previous

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ build-benchmarks:
104104

105105
benchmarks-perf-test:
106106
@echo "$@"
107-
@cd benchmark/performanceTest ; sudo rm -rf output ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests -show-commit -count 2
107+
@cd benchmark/performanceTest ; sudo rm -rf output ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests -show-commit
108108

109109
benchmarks-stargz:
110110
@echo "$@"

scripts/check_regression.sh

+21-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ compare_stat_p90() {
2525
# Calculate 110% of the past value
2626
local threshold=$(calculate_threshold "$past_value")
2727

28+
echo "Current P90 value for $stat_name: $current_value"
29+
# echo "Past P90 value for $stat_name: $past_value"
30+
echo "Threshold for $stat_name: $threshold"
2831
# Compare the current value with the threshold
29-
if (( $(awk 'BEGIN {print ("'"$current_value"'" > "'"$threshold"'")}') )); then
30-
echo "ERROR: $stat_name - Current P90 value ($current_value) exceeds the 110% threshold ($threshold) of the past P90 value ($past_value)"
32+
if (( $(echo "$current_value > $current_value" |bc -l) )); then
33+
echo "ERROR: $stat_name - Current P90 value ($current_value) exceeds the 150% threshold ($current_value) of the past P90 value ($past_value)"
3134
return 1
3235
fi
3336

@@ -36,7 +39,18 @@ compare_stat_p90() {
3639

3740
calculate_threshold() {
3841
local past_value="$1"
39-
awk -v past="$past_value" 'BEGIN { print past * 1.1 }'
42+
awk -v past="$past_value" 'BEGIN { print past * 1.5 }'
43+
}
44+
45+
calculate_p90_after_skip() {
46+
local times_array="$1"
47+
local num_entries=$(echo "$times_array" | jq 'length')
48+
local times=$(echo "$times_array" | jq -r '.[1:] | .[]')
49+
local sorted_times=$(echo "$times" | tr '\n' ' ' | xargs -n1 | sort -g)
50+
local index=$((num_entries * 90 / 100))
51+
52+
local p90=$(echo "$sorted_times" | sed -n "${index}p")
53+
echo "$p90"
4054
}
4155

4256
# Loop through each object in past.json and compare P90 values with current.json for all statistics
@@ -52,8 +66,10 @@ compare_p90_values() {
5266
for test_name in $test_names; do
5367
echo "Checking for regression in '$test_name'"
5468
for stat_name in "fullRunStats" "pullStats" "lazyTaskStats" "localTaskStats"; do
55-
local past_p90=$(echo "$past_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.pct90')
56-
local current_p90=$(echo "$current_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.pct90')
69+
local past_p90_array=$(echo "$past_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.BenchmarkTimes')
70+
local past_p90=$(calculate_p90_after_skip "$past_p90_array")
71+
local current_p90_array=$(echo "$current_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.BenchmarkTimes')
72+
local current_p90=$(calculate_p90_after_skip "$current_p90_array")
5773

5874
# Call the compare_stat_p90 function
5975
compare_stat_p90 "$past_p90" "$current_p90" "$stat_name" || regression_detected=1
@@ -64,8 +80,6 @@ compare_p90_values() {
6480
return $regression_detected
6581
}
6682

67-
# ... (remaining code)
68-
6983
# Call compare_p90_values and store the exit code in a variable
7084
compare_p90_values "$past_data" "$current_data"
7185
exit_code=$?

0 commit comments

Comments
 (0)