Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Pair benchmark evidence on one runner
pulse-triage[bot]9720f6726bc9
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.ymlindex 3b7436e947..63cb097d0b 100644--- a/.github/workflows/build-and-test.yml+++ b/.github/workflows/build-and-test.yml@@ -310,13 +310,21 @@ jobs:needs: changesif: needs.changes.outputs.code == 'true'runs-on: ubuntu-24.04- timeout-minutes: 30+ timeout-minutes: 35steps:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false+ - name: Checkout pull request base for paired comparison+ if: github.event_name == 'pull_request'+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: ${{ github.event.pull_request.base.sha }}+ path: benchmark-base+- name: Set up Gouses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0with:@@ -328,64 +336,48 @@ jobs:mkdir -p internal/api/frontend-modern/dist[ -f internal/api/frontend-modern/dist/index.html ] || \printf '<!doctype html><title>ci embed stub</title>\n' > internal/api/frontend-modern/dist/index.html+ if [ -d benchmark-base ]; then+ mkdir -p benchmark-base/internal/api/frontend-modern/dist+ [ -f benchmark-base/internal/api/frontend-modern/dist/index.html ] || \+ printf '<!doctype html><title>ci embed stub</title>\n' \+ > benchmark-base/internal/api/frontend-modern/dist/index.html+ fi- - name: Go benchmarks- timeout-minutes: 20+ - name: Go benchmarks (non-PR)+ if: github.event_name != 'pull_request'+ timeout-minutes: 15env:- PULSE_DATA_DIR: /tmp/pulse-bench-data- run: |- set -o pipefail- go test -bench=. -benchmem -count=5 -run=^$ -benchtime=100ms -timeout=5m \- ./pkg/metrics/ \- ./pkg/auth/ \- ./internal/api/ \- ./internal/monitoring/ \- ./internal/unifiedresources/ \- ./internal/dockeragent/ \- ./cmd/pulse-agent/ \- ./internal/hostagent/ \- ./internal/hostmetrics/ \- | tee bench-results.txt-- - name: Upload benchmark results- if: always()- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1- with:- name: bench-results- path: bench-results.txt- retention-days: 7+ PULSE_BENCH_SAMPLE_COUNT: "10"+ run: bash scripts/run-ci-benchmarks.sh++ - name: Paired base and candidate benchmarks (pull requests)+ if: github.event_name == 'pull_request'+ timeout-minutes: 25+ env:+ PULSE_BENCH_BASELINE_DIR: ${{ github.workspace }}/benchmark-base+ PULSE_BENCH_SAMPLE_COUNT: "10"+ run: bash scripts/run-ci-benchmarks.sh- name: Install benchstatrun: go install golang.org/x/perf/cmd/[email protected]- - name: Save benchmark baseline (main branch)- if: github.ref == 'refs/heads/main'- run: cp bench-results.txt bench-baseline.txt-- - name: Cache benchmark baseline (main branch)- if: github.ref == 'refs/heads/main'- uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5- with:- path: bench-baseline.txt- key: go-bench-baseline-${{ github.sha }}-- - name: Restore benchmark baseline (PRs)- if: github.event_name == 'pull_request'- uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5- with:- path: bench-baseline.txt- key: go-bench-baseline-- restore-keys: go-bench-baseline--- name: Compare benchmarks against baselineif: github.event_name == 'pull_request'run: |set -eo pipefail- if [ ! -f bench-baseline.txt ]; then- echo "No benchmark baseline found (first PR against main?). Skipping comparison."- exit 0- fiecho "=== Benchmark comparison (baseline vs current) ==="benchstat bench-baseline.txt bench-results.txt | tee bench-comparison.txtecho ""bash scripts/check-bench-regression.sh bench-comparison.txt++ - name: Upload benchmark evidence+ if: always()+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: bench-results+ path: |+ bench-results.txt+ bench-baseline.txt+ bench-comparison.txt+ if-no-files-found: warn+ retention-days: 7diff --git a/scripts/check-bench-regression.sh b/scripts/check-bench-regression.shindex 78a302e079..f2f1ba08a9 100755--- a/scripts/check-bench-regression.sh+++ b/scripts/check-bench-regression.sh@@ -2,15 +2,18 @@# check-bench-regression.sh — Parse benchstat output for significant regressions.## Usage: bash scripts/check-bench-regression.sh <benchstat-output-file>-# Exits 0 if no regressions >10% with p<0.05, exits 1 otherwise.+# Exits 0 if no regressions >10% with p<0.05, exits 1 otherwise. Comparisons+# with fewer than 10 samples are rejected because benchstat cannot treat them+# as a statistically trustworthy CI signal.## Expected input: benchstat comparison output containing lines like:-# BenchmarkName-N 1.23µ ± 1% 1.45µ ± 2% +17.89% (p=0.008 n=5)+# BenchmarkName-N 1.23µ ± 1% 1.45µ ± 2% +17.89% (p=0.001 n=10)set -euo pipefailTHRESHOLD=10 # percentP_MAX="0.05" # p-value significance level+MIN_SAMPLES=10 # benchstat's documented minimum for meaningful comparisonsCOMPARISON_FILE="${1:-}"if [ -z "$COMPARISON_FILE" ]; then@@ -24,7 +27,29 @@ if [ ! -f "$COMPARISON_FILE" ]; thenfiTMPFILE=$(mktemp)-trap 'rm -f "$TMPFILE"' EXIT+LOW_SAMPLE_FILE=$(mktemp)+trap 'rm -f "$TMPFILE" "$LOW_SAMPLE_FILE"' EXIT++# Refuse to turn an under-sampled comparison into a regression verdict. Five+# samples produce infinite 95% confidence intervals and were the source of+# repeated false failures on otherwise unrelated changes.+awk -v minimum="$MIN_SAMPLES" '+/p=[^)]*n=[0-9]+/ {+ match($0, /n=[0-9]+/)+ samples = substr($0, RSTART+2, RLENGTH-2) + 0+ if (samples < minimum) {+ }+}' "$COMPARISON_FILE" > "$LOW_SAMPLE_FILE"++low_sample_count=$(wc -l < "$LOW_SAMPLE_FILE" | tr -d ' ')+if [ "$low_sample_count" -ne 0 ]; then+ echo "BENCHMARK EVIDENCE INSUFFICIENT"+ echo "==============================="+ echo "At least ${MIN_SAMPLES} samples are required; ${low_sample_count} comparison(s) are under-sampled:"+ sed 's/^/ /' "$LOW_SAMPLE_FILE"+ exit 1+fi# Use POSIX-compatible awk to find statistically significant regressions.# Matches lines with +XX.XX% (p=0.XXX ...) and checks both thresholds.@@ -54,7 +79,7 @@ elseecho "$count regressed benchmark(s):"sed 's/^/ /' "$TMPFILE"echo ""- echo "To update the baseline after intentional performance changes:"- echo " Merge to main — the baseline is updated automatically on main branch pushes."+ echo "Reproduce the paired base/candidate comparison on the same idle host before"+ echo "classifying the change as intentional."exit 1fidiff --git a/scripts/run-ci-benchmarks.sh b/scripts/run-ci-benchmarks.shnew file mode 100755index 0000000000..98bf296ce1--- /dev/null+++ b/scripts/run-ci-benchmarks.sh@@ -0,0 +1,102 @@+#!/usr/bin/env bash+# Run the CI benchmark sample. When a baseline tree is supplied, execute the+# base and candidate on the same host in alternating order so host-to-host+# variance and run order are not mistaken for code regressions.++set -euo pipefail++CURRENT_DIR="${PULSE_BENCH_CURRENT_DIR:-$(pwd)}"+BASELINE_DIR="${PULSE_BENCH_BASELINE_DIR:-}"+SAMPLE_COUNT="${PULSE_BENCH_SAMPLE_COUNT:-10}"+BENCHTIME="${PULSE_BENCH_BENCHTIME:-100ms}"++if ! [[ "${SAMPLE_COUNT}" =~ ^[1-9][0-9]*$ ]]; then+ echo "PULSE_BENCH_SAMPLE_COUNT must be a positive integer." >&2+ exit 2+fi+if [[ ! -d "${CURRENT_DIR}" ]]; then+ echo "Benchmark candidate tree not found: ${CURRENT_DIR}" >&2+ exit 2+fi+if [[ -n "${BASELINE_DIR}" && ! -d "${BASELINE_DIR}" ]]; then+ echo "Benchmark baseline tree not found: ${BASELINE_DIR}" >&2+ exit 2+fi++PACKAGES=(+ ./pkg/metrics/+ ./pkg/auth/+ ./internal/api/+ ./internal/monitoring/+ ./internal/unifiedresources/+ ./internal/dockeragent/+ ./cmd/pulse-agent/+ ./internal/hostagent/+ ./internal/hostmetrics/+)++work_dir="$(mktemp -d)"+trap 'rm -rf "${work_dir}"' EXIT++run_sample() {+ local tree="$1"+ local output="$2"+ local label="$3"+ local round="$4"+ local data_dir="${work_dir}/${label}-${round}"++ mkdir -p "${data_dir}"+ echo "=== ${label} benchmark sample ${round}/${SAMPLE_COUNT} ==="+ (+ cd "${tree}"+ PULSE_DATA_DIR="${data_dir}" go test \+ -bench=. -benchmem -count=1 -run='^$' \+ -benchtime="${BENCHTIME}" -timeout=5m \+ "${PACKAGES[@]}"+ ) | tee -a "${output}"+}++run_unpaired() {+ local output="${CURRENT_DIR}/bench-results.txt"+ local data_dir="${work_dir}/candidate"++ mkdir -p "${data_dir}"+ (+ cd "${CURRENT_DIR}"+ PULSE_DATA_DIR="${data_dir}" go test \+ -bench=. -benchmem -count="${SAMPLE_COUNT}" -run='^$' \+ -benchtime="${BENCHTIME}" -timeout=5m \+ "${PACKAGES[@]}"+ ) | tee "${output}"+}++if [[ -z "${BASELINE_DIR}" ]]; then+ run_unpaired+ exit 0+fi++baseline_output="${CURRENT_DIR}/bench-baseline.txt"+candidate_output="${CURRENT_DIR}/bench-results.txt"+: > "${baseline_output}"+: > "${candidate_output}"++# Populate build and filesystem caches without adding a timed sample. This+# avoids consistently charging the first measured tree for cold setup.+for tree in "${BASELINE_DIR}" "${CURRENT_DIR}"; do+ (+ cd "${tree}"+ PULSE_DATA_DIR="${work_dir}/warmup" go test \+ -bench=. -count=1 -run='^$' -benchtime=1x -timeout=5m \+ "${PACKAGES[@]}" >/dev/null+ )+done++for ((round = 1; round <= SAMPLE_COUNT; round++)); do+ if ((round % 2 == 1)); then+ run_sample "${BASELINE_DIR}" "${baseline_output}" baseline "${round}"+ run_sample "${CURRENT_DIR}" "${candidate_output}" candidate "${round}"+ else+ run_sample "${CURRENT_DIR}" "${candidate_output}" candidate "${round}"+ run_sample "${BASELINE_DIR}" "${baseline_output}" baseline "${round}"+ fi+donediff --git a/scripts/tests/test-ci-benchmarks.sh b/scripts/tests/test-ci-benchmarks.shnew file mode 100755index 0000000000..2375ef7a79--- /dev/null+++ b/scripts/tests/test-ci-benchmarks.sh@@ -0,0 +1,76 @@+#!/usr/bin/env bash+# Contract tests for paired CI benchmark collection and verdict quality.++set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+WORK_DIR="$(mktemp -d)"+trap 'rm -rf "${WORK_DIR}"' EXIT++mkdir -p "${WORK_DIR}/bin" "${WORK_DIR}/candidate" "${WORK_DIR}/baseline"+cat > "${WORK_DIR}/bin/go" <<'EOF'+#!/usr/bin/env bash+printf '%s\t%s\n' "$PWD" "$*" >> "${FAKE_GO_LOG}"+cat <<'RESULT'+goos: linux+goarch: amd64+pkg: example.test/bench+cpu: test+BenchmarkExample-4 1 100 ns/op 0 B/op 0 allocs/op+PASS+ok example.test/bench 0.001s+RESULT+EOF+chmod +x "${WORK_DIR}/bin/go"++(+ cd "${WORK_DIR}/candidate"+ PATH="${WORK_DIR}/bin:${PATH}" \+ FAKE_GO_LOG="${WORK_DIR}/go.log" \+ PULSE_BENCH_CURRENT_DIR="${WORK_DIR}/candidate" \+ PULSE_BENCH_BASELINE_DIR="${WORK_DIR}/baseline" \+ PULSE_BENCH_SAMPLE_COUNT=2 \+ bash "${ROOT_DIR}/scripts/run-ci-benchmarks.sh" >/dev/null+)++[[ "$(grep -c '^BenchmarkExample' "${WORK_DIR}/candidate/bench-baseline.txt")" == 2 ]]+[[ "$(grep -c '^BenchmarkExample' "${WORK_DIR}/candidate/bench-results.txt")" == 2 ]]++# Warm-up is baseline then candidate. Measured rounds must alternate which tree+# goes first, avoiding a permanent order advantage.+mapfile -t calls < "${WORK_DIR}/go.log"+[[ "${#calls[@]}" == 6 ]]+[[ "${calls[2]}" == "${WORK_DIR}/baseline"$'\t'* ]]+[[ "${calls[3]}" == "${WORK_DIR}/candidate"$'\t'* ]]+[[ "${calls[4]}" == "${WORK_DIR}/candidate"$'\t'* ]]+[[ "${calls[5]}" == "${WORK_DIR}/baseline"$'\t'* ]]++cat > "${WORK_DIR}/adequate.txt" <<'EOF'+Example-4 100.0n ± 1% 111.0n ± 1% +11.00% (p=0.001 n=10)+EOF+set +e+output="$(bash "${ROOT_DIR}/scripts/check-bench-regression.sh" "${WORK_DIR}/adequate.txt" 2>&1)"+status=$?+set -e+if [[ "${status}" == 0 ]]; then+ echo "adequately sampled regression was not rejected" >&2+ exit 1+fi+grep -qF "BENCHMARK REGRESSION DETECTED" <<<"${output}"++cat > "${WORK_DIR}/undersampled.txt" <<'EOF'+Example-4 100.0n ± ∞ ¹ 111.0n ± ∞ ¹ +11.00% (p=0.008 n=5)+EOF+set +e+output="$(bash "${ROOT_DIR}/scripts/check-bench-regression.sh" "${WORK_DIR}/undersampled.txt" 2>&1)"+status=$?+set -e+[[ "${status}" != 0 ]]+grep -qF "BENCHMARK EVIDENCE INSUFFICIENT" <<<"${output}"++cat > "${WORK_DIR}/clean.txt" <<'EOF'+Example-4 100.0n ± 1% 105.0n ± 1% +5.00% (p=0.001 n=10)+EOF+bash "${ROOT_DIR}/scripts/check-bench-regression.sh" "${WORK_DIR}/clean.txt" >/dev/null++echo "all CI benchmark tests passed"diff --git a/scripts/tests/test_benchmark_workflow_contract.py b/scripts/tests/test_benchmark_workflow_contract.pynew file mode 100755index 0000000000..bc60ffab41--- /dev/null+++ b/scripts/tests/test_benchmark_workflow_contract.py@@ -0,0 +1,28 @@+#!/usr/bin/env python3+"""Guard the paired, adequately sampled benchmark workflow contract."""++from pathlib import Path+import unittest+++ROOT = Path(__file__).resolve().parents[2]+WORKFLOW = ROOT / ".github" / "workflows" / "build-and-test.yml"+++class BenchmarkWorkflowContractTest(unittest.TestCase):+ def test_prs_compare_base_and_candidate_on_one_runner(self) -> None:+ workflow = WORKFLOW.read_text(encoding="utf-8")+ benchmark_job = workflow[workflow.index(" benchmarks:") :]++ self.assertIn("ref: ${{ github.event.pull_request.base.sha }}", benchmark_job)+ self.assertIn("path: benchmark-base", benchmark_job)+ self.assertIn('PULSE_BENCH_SAMPLE_COUNT: "10"', benchmark_job)+ self.assertIn("bash scripts/run-ci-benchmarks.sh", benchmark_job)+ self.assertNotIn("go-bench-baseline-", benchmark_job)+ self.assertNotIn("actions/cache/restore@", benchmark_job)+ self.assertIn("bench-baseline.txt", benchmark_job)+ self.assertIn("bench-comparison.txt", benchmark_job)+++if __name__ == "__main__":+ unittest.main()