Skip to content

Cache and automatically run type checker benchmarks - #11684

Open
Bill Schnurr (bschnurr) wants to merge 8 commits into
mainfrom
benchmark/cache-base-results
Open

Bill Schnurr (bschnurr) wants to merge 8 commits into
mainfrom
benchmark/cache-base-results

Conversation

@bschnurr

@bschnurr Bill Schnurr (bschnurr) commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Automatically benchmark pull requests that change packages/pyright-internal/src/analyzer/.
  • Keep /benchmark as a maintainer-only rerun trigger for other pull requests.
  • Compare each PR synthetic merge commit against the exact main commit used as its first parent.
  • Cache validated main benchmark results by commit and hosted measurement profile.
  • Proactively populate the cache on relevant pushes to main and retain each raw result as a 90-day artifact.
  • Publish comparisons through artifacts, the job summary, and one updated bot comment without modifying PR branches.

What is compared

The candidate is GitHub's synthetic merge commit, which combines the PR's current head with its current main base. The baseline is that same exact main base commit:

main commit B ----------------------------> baseline benchmark
           \
            + PR head H -> synthetic M ---> candidate benchmark

comparison: M (B + PR changes) versus B

The trusted report workflow verifies that B is the merge commit's first parent. If the PR head or base changes before reporting validates the revisions, the report stops and a new run is required.

Cache and security

  • Relevant pushes to main benchmark GITHUB_SHA, save an exact-SHA/profile cache entry, and upload the result.
  • PR reports restore that same cache entry or benchmark the validated base on a cache miss.
  • The candidate workflow has read-only permissions and cannot access the shared cache.
  • The trusted report independently verifies analyzer path changes or an authorized rerun attempt.
  • No shared request label is used, so overlapping requests cannot revoke each other's authorization.
  • Candidate output crosses the trust boundary only as bounded, provenance-validated JSON.
  • Benchmark workflows never commit generated baseline files into contributor branches.

Benchmark history

The checked-in bootstrap results under build/benchmark/baselines/ include source commit metadata. build/benchmark/benchmark_history.ipynb can graph those results and export the static dashboard under docs/benchmark-results/. Automatic main results are retained through the Actions cache and 90-day artifacts rather than source commits.

Validation

  • python -m unittest discover -s build/benchmark -p "test_*.py" (52 tests)
  • Workflow YAML parsing
  • Prettier checks for changed workflows and documentation

Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Resolve PR revisions from trusted GitHub metadata before executing benchmark code. Retain and update checked-in baseline results with commit provenance, and add a notebook for benchmark history visualization and dashboard export.
Comment thread .github/workflows/typecheck_benchmark_pr.yml Fixed
Run candidate benchmarks in an unprivileged pull_request workflow and move trusted base caching, reporting, and baseline persistence to workflow_run. Authorize measured runs through maintainer-triggered reruns and update tests and documentation.
@bschnurr
Bill Schnurr (bschnurr) enabled auto-merge (squash) August 28, 2026 20:20
Export PNG previews alongside SVG dashboard charts and improve the single-baseline layout until additional hosted runs accumulate.
Run the repository's pinned Prettier formatter after notebook dashboard generation and commit the formatted HTML output.
@rchiodo

Rich Chiodo (rchiodo) commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR.

Comment thread .github/workflows/typecheck_benchmark_report.yml Outdated
Comment thread .github/workflows/typecheck_benchmark_pr.yml Outdated
Comment thread .github/workflows/typecheck_benchmark_report.yml Outdated
@rchiodo

Copy link
Copy Markdown
Collaborator

Result: ⚠️ partially-verified

Verification details

Verification: Isolated verification observed failures that were not classified as caused by this PR: Module-style benchmark test invocation, Benchmark unittest suite.

Summary: Five new comparator/profile tests passed. The 52-test benchmark suite ran 50 tests successfully, but two workflow tests errored because the container lacks Node.js. Verification is therefore partial; no PR-caused assertion failure was observed.

Test runs: 1 passed, 2 failed

  • Failed | unrelated to this PR | Module-style benchmark test invocation | python -m unittest build.benchmark.test_compare_benchmarks
  • Failed | unrelated to this PR | Benchmark unittest suite | python -m unittest discover -s build/benchmark -p "test_*.py"
  • Passed | New comparator and profile tests | python -m unittest test_compare_benchmarks.CompareBenchmarksTest.test_rejects_unexpected_source_revision test_compare_benchmarks.CompareBenchmarksTest.test_report_identifies_compared_revisions test_compare_benchmarks.CompareBenchmarksTest.test_allows_successful_benchmark_profile_change test_compare_benchmarks.CompareBenchmarksTest.test_incompatible_results_still_require_successful_measurements test_compare_benchmarks.CompareBenchmarksTest.test_pr_workflow_uses_matching_base_and_candidate_profiles
Module-style benchmark test invocation diagnostic output
ModuleNotFoundError: No module named 'build.benchmark'
Ran 1 test in 0.000s
FAILED (errors=1)
Benchmark unittest suite diagnostic output
Two workflow tests errored in _load_yaml with FileNotFoundError: [Errno 2] No such file or directory: 'node'.
Ran 52 tests in 0.057s
FAILED (errors=2)

@rchiodo Rich Chiodo (rchiodo) added the review-auto:changes-requested Automated review: posted blocking findings to address. label Sep 1, 2026
Benchmark relevant main commits into the exact-SHA cache and retain a downloadable artifact. Stop committing generated baselines to pull request branches and verify the synthetic merge commit uses the validated base.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the hosted benchmark automatically for pull requests that modify analyzer sources while retaining the maintainer command for other changes. Verify the automatic condition again in the trusted report workflow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bschnurr Bill Schnurr (bschnurr) changed the title Cache benchmark results by base commit Cache and automatically run type checker benchmarks Sep 14, 2026
Use the authorized workflow rerun attempt as the manual benchmark signal instead of a shared pull request label. This prevents an older report cleanup from revoking a newer overlapping request.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-auto:changes-requested Automated review: posted blocking findings to address.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants