Skip to content

ci(perf): base-vs-new journey benchmarks on hosted runners (CPU + counts, off the shared host) - #4834

Merged
Daniel Meppiel (danielmeppiel) merged 13 commits into
mainfrom
danielmeppiel-perf-bench-ci-main
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 13 commits into
mainfrom
danielmeppiel-perf-bench-ci-main

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds a Perf bench workflow that measures base vs new install journeys on hosted runners, so performance claims no longer wait for a quiet developer host.

  • Request: scripts/perf/bench_ci.sh request BASE NEW [journeys] [fixtures] [pairs] [rtt] pushes a short-lived perf-bench/* branch holding bench-request.env. bench_ci.sh fetch BRANCH waits for the run, prints the table and deletes the branch. Callers only do I/O.
  • Run: 3 runners each run interleaved base/new pairs (ABBA order) of tests/benchmarks/journeys.py, with the two CLIs installed non-editable from the two SHAs.
  • Report: CPU p50 per side (user+sys incl. children, wait4), the median per-pair new/base ratio (which cancels runner-to-runner speed differences), and deterministic counts (requests, spawns). Wall time is never reported.
  • Harness: brings in the CPU and spawn-count journeys harness from danielmeppiel-perf-scoreboard-and-uv (tests only), which the workflow needs.
  • Security: contents: read, no secrets, no pull_request_target, and persist-credentials: false on every checkout (SHAs are fetched anonymously). The request file is read as KEY=VALUE, never sourced, and every value is regex-validated before it reaches a run step via env:. No other workflow fires on perf-bench/**; every other push trigger is filtered to main or specific paths.

Issue and approved scope

Issue: Fixes #4825

Human scope-approval comment: #4825 (comment)

Does this PR complete the issue, or what remains? It completes it. QL W3b reviewed the trigger and permissions: ACCEPT, 0 blockers; both suggested hardenings are applied.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence:

  • uvx [email protected] check tests/ (the uv.lock pin): passed.
  • uvx [email protected] format --check tests/: passed.
  • python -m tests.quality.taxonomy --changed: passed (tm006).
  • pytest tests/benchmarks/test_scaling_guards.py -k test_bench: 4 passed (paired-ratio math, failed sample fails the report, missing shard fails the report, a hung command is killed at the deadline). This module runs in CI Tier 2 (ci-integration.yml).
  • python scripts/check_test_assertions.py: no finding in the changed modules.
  • End to end on hosted runners:
    • Branch copy of this workflow: run 45073693293 (4a1f9fd -> f0dab6c, tree-10, 9 pairs per side, about 4 min). Its counts match local counts exactly.
    • This branch with the hardenings: A/A run 45076411610 (same SHA on both sides) gave a paired ratio of 1.003, so the noise floor is about 1%.

Review fixes (Copilot round 1): fetch returns a failed run's status; the report fails on incomplete shards; timed runs keep the command timeout; the scoreboard preset honors explicit flags.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

Not applicable: no behaviour covered by an OpenAPM req-XXX changes.

…import counts

Adds install-locked-warm and install-frozen-warm journeys, wait4-based CPU,
an audit-hook spawn counter, and --preset scoreboard / --scoreboard FILE.

Co-authored-by: Copilot App <[email protected]>
…les; merge scoreboard chunks

Co-authored-by: Copilot App <[email protected]>
… counts)

Agents push a request branch and read the summary; three hosted runners
run interleaved base/new pairs of the journeys harness. CPU (wait4,
incl. children) and deterministic counts only, never wall time.

Co-authored-by: Copilot App <[email protected]>
…steps via env

QL W3b hardenings on #4825: persist-credentials false on every checkout
(the bench fetches the two SHAs anonymously) and no inline expressions
in run scripts.

Refs #4825

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Benchmark tooling can report success despite failed or missing samples, while measured commands lack timeouts, presets override explicit workload options, and the new report regression tests are excluded from CI.

5 open issues
What changed in this PR

Adds hosted base-vs-new performance benchmarking for APM install journeys, moving measurements off shared developer machines without making benchmarks a required PR check.

Changes:

  • Adds a three-runner workflow and request/fetch script for interleaved comparisons.
  • Reports CPU timing, paired ratios, request counts, and subprocess counts.
  • Extends the journey harness with warm-lockfile scenarios, scoreboard support, and report regression tests.
File Description
tests/​fixtures/​perf/​README.md Documents new journeys, CPU measurements, counts, and scoreboard usage.
tests/​benchmarks/​test_perf_benchmarks.py Adds paired-ratio and failed-sample regression tests.
tests/​benchmarks/​spawn_counter/​sitecustomize.py Records subprocess spawns and imported-module counts.
tests/​benchmarks/​journeys.py Adds CPU accounting, instrumentation, warm journeys, and scoreboard output.
tests/​benchmarks/​ci_bench.py Runs interleaved comparisons and aggregates shard reports.
scripts/​perf/​bench_ci.sh Submits benchmark requests and retrieves results.
.github/​workflows/​perf-bench.yml Validates requests, runs hosted benchmarks, and publishes reports.

Review effort: Balanced

Comment thread scripts/perf/bench_ci.sh Resolved
Comment thread tests/benchmarks/ci_bench.py Resolved
Comment thread tests/benchmarks/journeys.py Resolved
Comment thread tests/benchmarks/journeys.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Incomplete benchmark data can be reported as successful, and the fetch script masks workflow failures, preventing callers from reliably distinguishing valid measurements from failed runs.

5 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Abbreviated commit SHAs fail during fetch

.github/​workflows/​perf-bench.yml:121

Both request validators accept abbreviated SHAs, but git fetch URL "$sha" does not resolve a SHA prefix into a full commit ID. A normal 7- or 8-character commit prefix is treated as a remote ref name and fails with couldn't find remote ref, before either CLI can be benchmarked. Resolve accepted prefixes to full commit IDs before fetching, or require 40-character SHAs consistently in the dispatcher and workflow.

Medium severity Failed records can overwrite successful sample counts

tests/​benchmarks/​ci_bench.py:106

CPU samples exclude failed records, but the counts below come from the last record regardless of success. If the last pair fails during setup or partway through install, its empty or partial counters replace the counts from earlier successful samples while their CPU median is retained. Select the last successful record for requests, spawns, and modules too; leave counts unavailable if none succeeded.

Medium severity Report regression tests are excluded from PR CI

tests/​benchmarks/​test_perf_benchmarks.py:245

These two report regression tests are not selected by PR CI or the merge queue, despite the PR's validation claim. The Linux selection (.github/workflows/ci.yml:510-515) excludes tests/benchmarks, and the integration workflow selects only test_scaling_guards.py from that directory (ci-integration.yml:281). Move the tests into a CI-collected component test module with the required promise marker, or add a focused PR-time invocation.

Review effort: Balanced

…d wait4; preset honors explicit flags

- bench_ci.sh fetch returns the run's failure after printing the table
- ci_bench report fails when a side has fewer samples than runners x pairs
- journeys timed runs keep the command timeout (kill and reap on deadline)
- the scoreboard preset only fills options the caller did not pass
- bench tool tests move to test_scaling_guards.py, which CI runs (Tier 2)

Refs #4825

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The benchmark workflow can produce spurious failures on branch deletion and accepts unfetchable short SHAs, while uninstall profiling leaves stale installed state that causes subsequent benchmarks to measure an altered fixture.

No open issues 🎉

3 previously missed issues

In code that hasn't changed since last review

Medium severity Ignore request-branch deletion events

.github/​workflows/​perf-bench.yml:47

fetch deletes the request branch (scripts/perf/bench_ci.sh:57), which fires another matching push with github.event.deleted=true and the default branch's SHA. Validation then fails because main has no bench-request.env, creating a spurious failed run after a successful benchmark. Skip deletion events here, as .github/workflows/merge-train.yml:63 does for its temporary branches.

Medium severity Resolve abbreviated SHAs before fetching

.github/​workflows/​perf-bench.yml:121

Both request validators accept abbreviated commit IDs (7-39 hex characters), but git fetch <url> <sha> cannot resolve a remote commit abbreviation: it treats that string as a remote ref name. A request using an ordinary short SHA therefore passes validation and then fails all three shards, even when the commit exists. Resolve abbreviations to full commit IDs before fetching, or require 40-character SHAs in both the dispatcher and workflow validation.

Medium severity Reset cached install state after profiling uninstall

tests/​benchmarks/​journeys.py:604

With --runs 1 --profile, profiling uninstall calls installed() again and then removes a dependency while leaving is_installed=True. The following compile setup skips reinstalling, so it measures the altered project instead of the full fixture. Clear the cached installed state in a finally block around the profiling call at lines 637-638 as well.

5 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 949ecf4 into main Nov 22, 2026
50 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-perf-bench-ci-main branch November 22, 2026 23:28
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
… regenerate

Keeps #4843's native observation (a root half plus the enabledPlugins declaration half, native_gaps). Builds _surface_hits on train 5's entry-aware surfaces (JsonEntry, MergedHooks) and _observable. projected_cells keeps #4843's native projection plus the shared-root loose skill (#4559). #4751 fixed #4744, so the user-scope bin target-change cell drops its strict known and is required (known 9 -> 8, L15).

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Perf bench on CI runners: base-vs-new journey CPU and counts, off the shared host

2 participants