Skip to content

perf: make /check-golf --measure take minutes instead of hours#1400

Merged
jstoobysmith merged 3 commits into
leanprover-community:masterfrom
Vilin97:perf-check-golf
Jul 10, 2026
Merged

perf: make /check-golf --measure take minutes instead of hours#1400
jstoobysmith merged 3 commits into
leanprover-community:masterfrom
Vilin97:perf-check-golf

Conversation

@Vilin97

@Vilin97 Vilin97 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

A /check-golf run on a large golf PR (e.g. #1364, 129 changed files) currently takes ~2 hours: ~40 min building the head from scratch, then ~90 min measuring files strictly sequentially. Three changes bring this to minutes:

  1. Cache .lake/build across runs (actions/cache, keyed on toolchain+manifest with restore-keys picking the most recent entry) — the head build becomes incremental instead of from-scratch.
  2. Build only the changed modules — measurement only needs the measured files' imports built, not the whole library; their dependency cones come from the mathlib cache plus the restored build cache.
  3. Parallel measurement (--measure-jobs, default nproc). Heartbeats — the headline metric — are deterministic and unaffected by concurrency; wall-clock times are measured under load, so only large time deltas remain meaningful (noted in the docstring).

Also runs scripts/check_golf.py from the default branch instead of the PR head, eliminating the workflow/script version-skew failure that broke /check-golf on PRs predating #1356.

Expected: ~5–8 min on the standard 4-core runner for a 129-file PR with a warm cache (first run seeds the cache), and ~2–4 min for typical golf PRs.

Stacked on #1399 (includes its one-line fix).

🤖 Generated with Claude Code

Vilin97 and others added 2 commits July 9, 2026 00:29
The measure-path file selection in scripts/check_golf.py references a
nonexistent FileReport attribute (def_body_changed); the field is named
def_value_changed. Every /check-golf --measure run since leanprover-community#1356 crashes
with an AttributeError after building the head, so the report comment
is never updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…arallel measure)

Three changes that turn a ~2h run into minutes:

1. Cache .lake/build across check-golf runs (keyed on toolchain+manifest,
   restore-keys pick the most recent entry), so the head build is
   incremental instead of from-scratch (~40 min saved).
2. Build only the changed modules' dependency cones instead of the whole
   library: measurement only needs the measured files' imports built.
3. Measure files concurrently (--measure-jobs, default nproc). Heartbeats
   are deterministic and unaffected by parallelism; wall-clock times are
   measured under load, so only large time deltas remain meaningful
   (documented in the docstring).

Also run scripts/check_golf.py from the default branch rather than the PR
head, so the workflow file and script can never skew apart (the failure
mode that broke /check-golf on PRs predating leanprover-community#1356).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for this PR, which will now be reviewed. If submitting to ./Physlib or ./QuantumInfo, please see our review guidelines if you are not familiar with the process. You should expect a back and forth with a reviewer before your PR is merged. See also that link for how to add appropriate labels to your PR. The PR will also go through a number of automated checks. You can learn more about these here, including how to run them locally.

If you are submitting to ./PhyslibAlpha there will be a lighter review process, though your PR must still pass the automated checks.

If you want to bring attention to this PR, please write a message on this thread of the Lean Zulip.

Important: If a reviewer adds an awaiting-author label to your PR, once you have addressed the review comments, please remove that label by adding a comment with -awaiting-author. This helps us keep track of reviews.

@jstoobysmith jstoobysmith self-assigned this Jul 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file

@jstoobysmith

Copy link
Copy Markdown
Member

awaiting-author

@github-actions github-actions Bot added the awaiting-author A reviewer has asked the author a question or requested changes label Jul 9, 2026

@jstoobysmith jstoobysmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good - approved

@jstoobysmith jstoobysmith added ready-to-merge This PR is approved and will be merged shortly and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 10, 2026
@jstoobysmith jstoobysmith merged commit 1c40d11 into leanprover-community:master Jul 10, 2026
6 checks passed
Vilin97 added a commit to Vilin97/physlib that referenced this pull request Jul 10, 2026
- CKMMatrix/Basic: the nine phase-shift component lemmas now use squeezed
  simp only [...] sets instead of broad simp (review: 'a bit bad as not
  simp only').
- Grad: replace the rw-with-hypothesis ending of distGrad_eq_sum_basis by
  a direct (distGrad_inner_eq ..).trans h1.symm term (review: 'odd').
- Remove scripts/__pycache__/check_golf.cpython-312.pyc that entered via
  the leanprover-community#1400 merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jstoobysmith pushed a commit that referenced this pull request Jul 11, 2026
Running scripts/check_golf.py locally leaves __pycache__/ behind, and one
.pyc already slipped into a commit once (#1400, since removed). Ignore
Python bytecode so it cannot happen again.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR is approved and will be merged shortly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants