Skip to content

Commit e3c9110

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 3794a90 commit e3c9110

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.github/workflows/benchmark_regression_test.yml

Lines changed: 2 additions & 2 deletions
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,7 +52,7 @@ 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:

scripts/check_regression.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ compare_stat_p90() {
2727

2828
# Compare the current value with the threshold
2929
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)"
30+
echo "ERROR: $stat_name - Current P90 value ($current_value) exceeds the 150% threshold ($threshold) of the past P90 value ($past_value)"
3131
return 1
3232
fi
3333

@@ -36,7 +36,18 @@ compare_stat_p90() {
3636

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

4253
# Loop through each object in past.json and compare P90 values with current.json for all statistics
@@ -52,8 +63,10 @@ compare_p90_values() {
5263
for test_name in $test_names; do
5364
echo "Checking for regression in '$test_name'"
5465
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')
66+
local past_p90_array=$(echo "$past_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.BenchmarkTimes')
67+
local past_p90=$(calculate_p90_after_skip "$past_p90_array")
68+
local current_p90_array=$(echo "$current_json" | jq -r --arg test "$test_name" '.benchmarkTests[] | select(.testName == $test) | .'"$stat_name"'.BenchmarkTimes')
69+
local current_p90=$(calculate_p90_after_skip "$current_p90_array")
5770

5871
# Call the compare_stat_p90 function
5972
compare_stat_p90 "$past_p90" "$current_p90" "$stat_name" || regression_detected=1
@@ -64,8 +77,6 @@ compare_p90_values() {
6477
return $regression_detected
6578
}
6679

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

0 commit comments

Comments
 (0)