Skip to content

Commit da4b666

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 da4b666

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

.github/workflows/benchmark_regression_test.yml

Lines changed: 5 additions & 3 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,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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ compare_stat_p90() {
2222
local current_value="$2"
2323
local stat_name="$3"
2424

25-
# Calculate 110% of the past value
25+
# Calculate 115% of the past value
2626
local threshold=$(calculate_threshold "$past_value")
2727

2828
# 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)"
29+
if (( $(echo "$current_value > $current_value" |bc -l) )); then
30+
echo "ERROR: $stat_name - Current P90 value ($current_value) exceeds the 115% threshold ($current_value) 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.15 }'
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)