Repository navigation
Speed up Erdős 97 coverage certificate compilation - #1079
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Medium impact] No blocking issue was found in this performance refactor. SummarySpeeds up certificate checks without changing the claims they prove.
No actionable issues found. External source fidelity and the original project's provenance were not independently reverified; this refactor leaves their claims and metadata unchanged. Reviews (1) · Last reviewed commit: "Speed up Erdős 97 coverage certificate c..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 1,833 tracked declarations across 186 modified files kept their type; only proofs / definition bodies changed. Also: 28 declarations added, 0 removed. A reorganization moves declarations between files, which shows up here as an add in one file and a remove in another. ➕ Declarations added (28)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 6,867,195 → 3,950,924 (-2,916,271, -42.5%). Commands: 1,701 → 1,730. Per-file wall sum: 1101.0 s → 769.5 s (-30.1%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 92 compared — 55 cheaper, 1 costlier, 36 within noise (threshold: |Δ heartbeats| ≥ 1,000 and ≥ 1%). Both sides are elaborated against the merge-base build of the pool — sound when only proofs and definition bodies change; a file whose statements changed may fail there and is flagged ⚠. Heartbeats come from disjoint root command traces with
Per-project compile cost (top 2 of 2 projects by |Δ heartbeats|):
New files — absolute profileTotal heartbeats: — maxHeartbeats units across 0 valid files (94 added LOC). Sum of Count-heartbeats wall-clock total: 0.00 s. Repeated import cost inside Heartbeat values sum disjoint root command traces with LOC counts added lines in the profiled Lean files from this PR diff.
Aggregate phase totals
Advisory only — never blocks merge. Full log uploaded as the |
There was a problem hiding this comment.
Accepted at a526db661435. The packed replay proves the existing Erdős 97 certificate checks with less total build work.
- The new decider is equivalent to the existing chunk predicate for arbitrary claims and chunk bounds. The shift proofs preserve
UInt64’s modulo-64 behavior. The word shortcut requires both a zero mask and an empty witness array. All 375 node audits, 88 conflict-cover audits and 64 summary audits use kernel-checked decisions. Packed replay - The import changes preserve the public import list. I checked the retained manifest comparison across all 269 project modules. It found zero changes or removals among the 132,021 existing records. The new decider’s body is present as a safe definition in the private module section, and the retained axiom and trust audits passed. Validation evidence
- The retained clean builds took 189.88 s and 154.21 s. The advisory profiler measured a higher elaboration cost in the replay helper itself, where the PR adds the equivalence proofs. Across all 92 comparable files, total heartbeats fell 42.5%. All 94 failed measurements reference the new decider absent from the profiler’s merge-base imports. The exact-head build checks the complete dependency graph. Proof Profile · Lean Action CI
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | certificate replay and import optimization |
| Introduces tech debt | 🛑 yes |
| Maintainability | ✅ improved |
| Brittleness | ➖ unchanged |
| Risk | ✅ low |
The lower audit cost and narrower imports outweigh the duplicated replay logic, whose agreement with the checker is enforced by explicit equivalence proofs.
Findings (1)
- duplicated-logic —
LeanPool/Erdos97ConvexOctagon/CoverageCertificateReplay.lean:417
packedActiveRowrepeats the witness routing and child guards inreplayActiveRow, andpackedPruningrepeats the row partition checks. A change to those rules now has to be carried through the checker and both replays. As a follow-up, share the traversal and common guards between the replays, then rerun the chunk benchmark to verify that the shared code retains the speedup.
Tokens: 2,861,170 in / 19,532 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $11.7377 (Standard API equivalent; uncached input) (long-context rate)
Automated review against .github/REFACTOR_REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.
Ready for review. Erdős 97 cuts clean build wall time by 18.79% with every existing declaration preserved.
Project and changes
The Lean Pool source profile at
ebaad62ab60d27fe11a5242fcbd7246d0d74d061attributed 438.3 of this 269-module project's 638.4 source-elaboration seconds to 94 certificate fact modules. They shared one replay implementation. The proof ofcoverageBranchNodes_6_15_00000accounted for 3.70 seconds in that profile.Natbit operations. The equivalence to the existing checker covers arbitrary claims, preserves the 64-bit shift semantics, and justifies skipping a word loop when both its mask and witness stream are empty. The 375 node audits select the new decider locally.decide +kernelto avoid repeating closed computation during elaboration.CoverageCertificateFacts80went from 2,074 artifacts to 750.Measurements
Base commit
90362e7ab43700093d9bb548c978817ff55c9342. Optimized commita526db6614351800d56c95813dabf2aa3f2d4df8. Both measurements used Lean and Mathlib v4.36.0, with Mathlib atfc4f59e577feb1a4956671bc04ac18aaaf8cd842.CoverageCertificateFacts80CoverageCertificateConflictCovers21CoverageSummaryData00Consecutive clean builds ran in the same isolated Azure worktree, pinned to logical CPUs 0–7. Each removed the selected project's Lean and IR outputs under
.lake/buildand reused the pinned dependency artifacts. Both builds compiled all 269 project modules. The module times are Lake's rounded times under concurrent compilation. The wall-time percentage reflects this VM and CPU affinity.Declaration audit
Before the edit and again after the final build, I used
Lean.readModuleDataPartsto read every module's exported, server, and private.oleansections and streamed the manifest throughzstd. The comparison includes full names, universe parameters, structural types, non-theorem values, safety and reducibility metadata, inductive and recursor data, and compiler-generated names. It elides theorem bodies and source metadata.All 132,021 existing records match, with zero changed or missing records. The 245 added records come from the packed replay and the auxiliary proofs generated by the kernel audits. The initial audit caught changes to two generated private proofs in
PairStateExactness. Restoring that module's original imports restored the exact records. The diff preserves all public imports.The local audit used the following commands with the same module list on both builds.
lake env lean --run ../Manifest.lean ../project-modules.txt | zstd -T1 -q -3 -o ../final-manifest.jsonl.zst python3 ../compare-manifests.py ../base-manifest.jsonl.zst ../final-manifest.jsonl.zstValidation
The project build completed with warning-as-error enabled. The repository's project shard validation covered declaration linting, registered declarations, allowed axioms, the backdoor audit, and build messages. The style, repository static-quality, and generated-index checks also passed.