-
Notifications
You must be signed in to change notification settings - Fork 60
Establish performance baselines and regression detection #3441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dheerajodha
wants to merge
6
commits into
conforma:main
Choose a base branch
from
dheerajodha:EC-1819
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
da28638
feat(EC-1819): add performance baselines and regression detection
dheerajodha fef1f92
fix: address issues in baseline regression detection
0c7c7b8
fix: address review feedback on baseline regression detection
9f4a1d9
fix: harden benchmark scripts against injection and edge cases
3311669
docs: document stress benchmark baseline and regression detection
1470f8d
fix: match generate-baseline workload to CI and improve diagnostics
dheerajodha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "peak_rss_bytes": 2250485760, | ||
| "ns_per_op": 2567888013, | ||
| "components": 10, | ||
| "workers": 10, | ||
| "commit": "fc37eb13", | ||
| "date": "2026-08-11", | ||
| "go_version": "1.26.3" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/bin/bash | ||
| # Copyright The Conforma Contributors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Compares current benchmark results against a stored baseline and exits | ||
| # non-zero if any metric regresses beyond the configured threshold. | ||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| BASELINE="${SCRIPT_DIR}/baseline.json" | ||
| THRESHOLDS="${SCRIPT_DIR}/thresholds.json" | ||
| BENCHMARK_OUTPUT="${1:-${SCRIPT_DIR}/benchmark-output.txt}" | ||
|
|
||
| if [[ ! -f "$BASELINE" ]]; then | ||
| echo "No baseline found, skipping comparison." | ||
| exit 0 | ||
| fi | ||
|
dheerajodha marked this conversation as resolved.
|
||
|
|
||
| if [[ ! -f "$THRESHOLDS" ]]; then | ||
| echo "No thresholds file found, skipping comparison." | ||
| exit 0 | ||
| fi | ||
|
dheerajodha marked this conversation as resolved.
|
||
|
|
||
| if [[ ! -f "$BENCHMARK_OUTPUT" ]]; then | ||
| echo "No benchmark output found at ${BENCHMARK_OUTPUT}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| line=$(grep '^BenchmarkStress' "$BENCHMARK_OUTPUT" || true) | ||
| if [[ -z "$line" ]]; then | ||
|
dheerajodha marked this conversation as resolved.
|
||
| echo "No BenchmarkStress results found in output." | ||
| exit 1 | ||
| fi | ||
|
dheerajodha marked this conversation as resolved.
|
||
|
|
||
| read -r current_ns current_rss baseline_ns baseline_rss threshold_rss threshold_time < <( | ||
| BENCH_LINE="${line}" BASELINE_PATH="${BASELINE}" THRESHOLDS_PATH="${THRESHOLDS}" python3 -c " | ||
|
dheerajodha marked this conversation as resolved.
|
||
| import json, os, re, sys | ||
| line = os.environ['BENCH_LINE'] | ||
| def extract(pattern): | ||
| m = re.search(pattern, line) | ||
| return m.group(1) if m else '' | ||
| ns = extract(r'([\d.]+)\s+ns/op') | ||
| rss = extract(r'([\d.]+)\s+peak-RSS-bytes') | ||
|
dheerajodha marked this conversation as resolved.
|
||
| if not ns or not rss: | ||
| print('Failed to parse benchmark metrics from output.', file=sys.stderr) | ||
| sys.exit(1) | ||
| b = json.load(open(os.environ['BASELINE_PATH'])) | ||
| t = json.load(open(os.environ['THRESHOLDS_PATH'])) | ||
| print(ns, rss, b['ns_per_op'], b['peak_rss_bytes'], t['peak_rss_percent'], t['ns_per_op_percent']) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| " | ||
|
dheerajodha marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| if awk -v rss="$baseline_rss" -v ns="$baseline_ns" 'BEGIN {exit !(rss==0 || ns==0)}'; then | ||
|
dheerajodha marked this conversation as resolved.
|
||
| echo "Baseline contains zero values, cannot compute regression." | ||
|
dheerajodha marked this conversation as resolved.
|
||
| exit 1 | ||
| fi | ||
|
|
||
| rss_change=$(awk -v cur="$current_rss" -v base="$baseline_rss" 'BEGIN {printf "%.1f", ((cur - base) / base) * 100}') | ||
| time_change=$(awk -v cur="$current_ns" -v base="$baseline_ns" 'BEGIN {printf "%.1f", ((cur - base) / base) * 100}') | ||
|
|
||
| baseline_rss_mb=$(awk -v val="$baseline_rss" 'BEGIN {printf "%.0f", val / 1048576}') | ||
| current_rss_mb=$(awk -v val="$current_rss" 'BEGIN {printf "%.0f", val / 1048576}') | ||
| baseline_secs=$(awk -v val="$baseline_ns" 'BEGIN {printf "%.1f", val / 1000000000}') | ||
| current_secs=$(awk -v val="$current_ns" 'BEGIN {printf "%.1f", val / 1000000000}') | ||
|
|
||
| echo "" | ||
| echo "=== Benchmark Comparison ===" | ||
| echo "" | ||
| printf "%-20s %10s %10s %10s %10s\n" "Metric" "Baseline" "Current" "Change" "Threshold" | ||
| printf "%-20s %10s %10s %9s%% %9s%%\n" "Peak RSS" "${baseline_rss_mb} MB" "${current_rss_mb} MB" "$rss_change" "$threshold_rss" | ||
| printf "%-20s %10s %10s %9s%% %9s%%\n" "Execution time" "${baseline_secs}s" "${current_secs}s" "$time_change" "$threshold_time" | ||
| echo "" | ||
|
|
||
| failed=0 | ||
|
|
||
| rss_exceeded=$(awk -v change="$rss_change" -v thresh="$threshold_rss" 'BEGIN {print (change > thresh) ? 1 : 0}') | ||
| time_exceeded=$(awk -v change="$time_change" -v thresh="$threshold_time" 'BEGIN {print (change > thresh) ? 1 : 0}') | ||
|
|
||
| if [[ "$rss_exceeded" == "1" ]]; then | ||
| echo "FAIL: Peak RSS regressed by ${rss_change}% (threshold: ${threshold_rss}%)" | ||
| failed=1 | ||
| fi | ||
|
|
||
| if [[ "$time_exceeded" == "1" ]]; then | ||
| echo "FAIL: Execution time regressed by ${time_change}% (threshold: ${threshold_time}%)" | ||
| failed=1 | ||
| fi | ||
|
|
||
| if [[ "$failed" == "0" ]]; then | ||
| echo "PASS: No regressions detected." | ||
| fi | ||
|
|
||
| exit "$failed" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "peak_rss_percent": 15, | ||
| "ns_per_op_percent": 20 | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.