Repository navigation
Speed up MovingSofa certificate compilation - #1064
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 the certificate changes. SummaryThis PR speeds up MovingSofa certificate checks without changing their original statements.
The supplied measurements report lower build time and peak concurrent compiler memory. Builds and benchmarks were not rerun during this review. External upstream sources were not independently rechecked. Reviews (1) · Last reviewed commit: "Speed up MovingSofa certificate compilat..." · Reviewed by Greptile |
There was a problem hiding this comment.
Source review passed for 911f1a0e38f536ade664a3b8a9de6ece418f03d9.
- Part E proves that the shift-based evaluator returns the original rejection Boolean and retains the finer fallback. All 30 bundle changes are confined to switching the local evaluator and updating its comment. I verified all 32 files at the historical reproduction pin against the recipe digests.
- The cap and niche evaluators prove equality to the original interval endpoints before checking the same subtotals. Part B checks a covering rectangle for each of the 64 first cells, then proves the original checks for all 4,096 pairs by containment and monotonicity.
- The reported matched build pair measured 5.41% lower CPU time and 12.61% lower peak combined anonymous compiler memory. The single-compiler anonymous peak was 0.37% higher. The combined peak depends on which modules overlap. Benchmark and declaration audit
The hosted Proof Profile measured higher elaboration cost in the two comparable helper modules. Heartbeats rose 13.6% in FixedPointResiduals and 31.1% in ProductCellBounds. The merge-base profiling environment lacked the new evaluator and helper declarations, so it could not compare the affected certificates. The full-project build pair captures the certificate savings and helper overhead together. Proof Profile
The required Lean build passed at this head. Lean Action CI
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | certificate replay optimization |
| Introduces tech debt | 🛑 yes |
| Maintainability | 🛑 regressed |
| Brittleness | 🛑 more_brittle |
| Risk | 🟡 medium |
Keep the faster arithmetic and the reusable Part B box proof, and give the area contact formulas a single implementation before merging.
Findings (1)
- duplicated-logic —
LeanPool/MovingSofa/Development/Geometry/Foundations/AreaCertificateReplay.lean:161
evalFromTrigduplicates all five phase branches and the contact offsets fromevalZ. The equality proof catches divergence at compile time, so a geometry correction requires matching edits in both files. MoveevalFromTrigintoAreaCertificateInputsand have both evaluators call it with their respective sine and cosine intervals. That extraction passed both area certificate builds and the four definitional equality checks used by the contact soundness proof in a scratch experiment.
Tokens: 3,958,014 in / 16,976 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $16.0867 (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.
request_changes is an ask, not a close: of the reviewer's past request_changes verdicts, 39% were merged after a human looked. Read the findings before acting on the verdict.
Proof profile (new / modified Lean files)
This build covers the added modules and their dependency cones on top of the measurement environment; modified files are measured without rebuilding the pool. Statement changes✅ No statements changed — all 49,917 tracked declarations across 36 modified files kept their type; only proofs / definition bodies changed. Also: 47 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 (47)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 60,614 → 70,301 (+9,686, +16.0%). Commands: 255 → 307. Per-file wall sum: 12.2 s → 15.6 s (+27.9%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 2 compared — 0 cheaper, 2 costlier, 0 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
New files — absolute profileTotal heartbeats: 7,586 maxHeartbeats units across 1 valid file (411 added LOC). Sum of Count-heartbeats wall-clock total: 2.05 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
Slowest changed modules (from
|
| Changed module | Lake time |
|---|---|
LeanPool.MovingSofa.Development.Geometry.Foundations.AreaCertificateReplay |
2.70 s |
Per-file `lean --profile` output
LeanPool/MovingSofa/Development/Geometry/Foundations/AreaCertificateReplay.lean
import took 878ms
cumulative profiling times:
attribute application 0.443ms
compilation (IR) 1.11ms
compilation (LCNF base) 12ms
compilation (LCNF impure) 5.41ms
compilation (LCNF mono) 11.3ms
congr simp thm 2.2ms
declTypeLinter 6.36ms
elaboration 79.2ms
fix level params 0.451ms
import 878ms
initialization 26.8ms
instantiate metavars 0.641ms
interpretation 180ms
let-to-have transformation 2.65ms
linting 20.9ms
module linting 0.0243ms
parsing 17.1ms
process pre-definitions 9.39ms
share common exprs 2.6ms
simp 43.3ms
tactic execution 127ms
tacticAnalysis 5.47ms
type checking 54.1ms
typeclass inference 89.9ms
real 1.83
user 1.22
sys 0.68
Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.
Ready for review. MovingSofa’s peak concurrent compiler anonymous memory fell 12.61% in the matched Azure VM build, and all original declarations matched.
Changes
MovingSofa ranked first in the repository’s cold-build cost table. The baseline logged 1,018.4 summed Lake seconds across its Part E certificate bundles. CI cost table
Declaration audit
Base
51531356f36615cebb2c8937806132eb779b58d1· head911f1a0e38f536ade664a3b8a9de6ece418f03d9. The pre-edit base wasc0a34d020d4d0523e8be1a2b5b7f01e1c7c0ffdb. The current parent’s clean build independently reproduced the compressed base manifest byte for byte.A local Lean inspector read the exported, server, and private parts through
Lean.readModuleDataPartsfor every project module. The structural records include ownership, name, visibility tier, universe parameters, full elaborated type, kind, safety, reducibility, inductive and recursor metadata, non-theorem values, and compiler-generated names. The comparison omits theorem proof bodies and kernel-inert expression metadata.All 250,316 original records covering 106,984 declarations matched. The 440 added records belong to the new replay helpers and their generated declarations. The separately compiled benchmark checkout reproduced the final manifest with zero differences.
51dfdc285f73694b00862a5cdc567abee349f706a655e0d4cce73892ecb068dd557f464629df6907b368dcb85dfbfb9f7bc031bd9f526420abb61f3e33e446ceMeasurements
Both sides rebuilt every owned module on the same Azure VM with Lean 4.36.0 and Mathlib
fc4f59e577feb1a4956671bc04ac18aaaf8cd842. They started together on disjoint sets of four physical cores with SMT, using warm dependency, Isoperimetric, and linter-plugin artifacts. Only project outputs were cleared. The base built 65 modules and the head built 66.The base used CPUs
8-15and the head used0-7.An earlier sequential clean comparison was 585.67 → 541.53 s elapsed and 2,714.50 → 2,514.01 s CPU. Host load and parallel scheduling affect elapsed time. Every 0.5 seconds, the sampler added
RssAnon + VmSwapacross the active MovingSofa Lean compiler processes in each worktree. The reported build peak is the maximum of those sums. The single-compiler peak comes from the same samples. The concurrent peak depends on how Lake schedules overlapping modules. This benchmark measured one matched pair for the final patch.Validation
lake --wfail --no-build build +LeanPool.MovingSofa.Imports. The per-file time check covered all 37 changed files. The slowest was 116 s with a 600 s limit.python -m lean_pool.shard_validation --repo . --units MovingSofapassed the repository’s Mathlib/Batteries declaration linters, declaration resolution, permitted-axiom, environment trust and option, and compiler-message audits.lake --wfail exe lint-style LeanPool.MovingSofa.Importsandpython -m lean_pool.quality --repo . --static-only.lake exe mk_all --module --check,lake exe mk_all --check,python -m lean_pool.rebase_fastpath check-index, documentation toolchain and Mathlib pin parity, andgit diff --check.lake shake --force --keep-public --keep-implied --explain LeanPool.MovingSofa.Importsreviewed the existing import graph and the new replay module’s imports. The explicitomegatactic import is marked for preservation.Local compiled validation covers MovingSofa. GitHub CI covers the full pool.