Repository navigation
Speed up ExtriangulatedRealization builds - #1054
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Low impact] The refactor appears safe to merge, with existing declarations and import paths preserved. SummarySplits the connecting-map definitions and triangle proofs so they can build on separate paths. Two private helpers check expensive proof steps over abstract categories.
Reviews (1) · Last reviewed commit: "Speed up ExtriangulatedRealization build..." · Reviewed by Greptile |
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 21 tracked declarations across 4 modified files kept their type; only proofs / definition bodies changed. Also: 1 declaration added, 21 removed. A reorganization moves declarations between files, which shows up here as an add in one file and a remove in another. ➕ Declarations added (1)
➖ Declarations removed (21)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 654,596 → 481,988 (-172,608, -26.4%). Commands: 37 → 39. Per-file wall sum: 82.7 s → 50.0 s (-39.6%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 1 compared — 1 cheaper, 0 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: 712,005 maxHeartbeats units across 2 valid files (317 added LOC). Sum of Count-heartbeats wall-clock total: 49.59 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.ExtriangulatedRealization.Realization.Shadow |
33.00 s |
LeanPool.ExtriangulatedRealization.Realization.ExtensionMaps |
19.00 s |
LeanPool.ExtriangulatedRealization.Realization.TriangleProofs |
16.00 s |
Per-file `lean --profile` output
LeanPool/ExtriangulatedRealization/Realization/ExtensionMaps.lean
import took 1.68s
type checking took 9.41s
type checking took 542ms
elaboration took 117ms
type checking took 3.04s
elaboration took 139ms
type checking took 3.75s
type checking took 566ms
type checking took 529ms
type checking took 1.25s
cumulative profiling times:
attribute application 51ms
declTypeLinter 7.35ms
elaboration 492ms
fix level params 1.13ms
import 1.68s
initialization 25.9ms
instantiate metavars 0.21ms
interpretation 135ms
let-to-have transformation 0.469ms
linting 13.9ms
module linting 0.0184ms
parsing 4.37ms
process pre-definitions 17.8ms
share common exprs 4.86ms
tacticAnalysis 2.73ms
type checking 19.1s
typeclass inference 197ms
real 21.67
user 20.56
sys 0.97
LeanPool/ExtriangulatedRealization/Realization/TriangleProofs.lean
import took 673ms
type checking took 738ms
tactic execution of Lean.Parser.Tactic.refine took 468ms
tactic execution of Lean.Parser.Tactic.exact took 204ms
type checking took 5.21s
type checking took 1.71s
type checking took 531ms
tactic execution of Lean.Parser.Tactic.refine took 242ms
tactic execution of Lean.Parser.Tactic.change took 127ms
tactic execution of Lean.Parser.Tactic.rewriteSeq took 152ms
type checking took 8.58s
cumulative profiling times:
attribute application 1.67ms
congr simp thm 1.29ms
declTypeLinter 11ms
elaboration 230ms
fix level params 5.88ms
import 673ms
initialization 30.3ms
instantiate metavars 6.32ms
interpretation 175ms
let-to-have transformation 1ms
linting 49.5ms
module linting 0.0343ms
parsing 12.2ms
process pre-definitions 35.8ms
share common exprs 20.3ms
simp 29ms
tactic execution 1.81s
tacticAnalysis 4.06ms
type checking 16.8s
typeclass inference 683ms
real 18.69
user 20.34
sys 1.11
Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.
Vilin97
left a comment
There was a problem hiding this comment.
Approve at cebf74cdfb2e85373d827d3d4d070e0fe48095fc.
- The connecting-map definitions and naturality proofs moved without changing their statements. The old
ExtensionsandTrianglesimports still expose the moved declarations. The matrix-lift equality and the isomorphism cancellation are the same steps factored into private categorical lemmas. - The compiled audit accounts for all 1,606 existing names, and the copyright headers are retained. The matched clean build went from 209.40 s to 155.21 s, with user CPU time dropping from 306.97 s to 251.23 s. Hosted profiling also measured 26.4% fewer heartbeats in
Shadow.lean. The profile's per-file removals correspond to the declarations moved into the new modules. Proof Profile - All applicable required checks passed. Lean Action CI
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | Module split and proof extraction |
| Introduces tech debt | ✅ no |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
The split shortens the build’s critical path, and the extracted lemmas make failures easier to localize while preserving the import paths callers use.
Tokens: 2,443,516 in / 12,170 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $9.9566 (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. The
ExtriangulatedRealizationclean build took 25.9% less wall time in the matched Azure VM run.Changes
The source profile put about 41% of the project's source-attributed time in
ShadowandExtensions. The project had 61 modules, and the expensive realization steps were on the same build path. Lean Pool source profileExtensionMaps, so their naturality and bijectivity proofs inExtensionscan compile alongsideTriangleProofs. The originalExtensionsandTrianglesimports still expose their original declarations.kInjandrealTriangletogether so Lean reuses the original generated cancellation proof. Regenerate the project's public import index.Declaration audit
Read the exported, server, and private
.oleanconstant tables with Lean before and after the changes. Compared SHA-256 digests of the full expression DAGs, including binder annotations, universe parameters, declaration kind, safety, and non-proof values. The only normalization was the source-module component of generatedinstbinder scope names in the two moved modules.All 1,606 existing names matched, including private and generated declarations. There were 28 module moves, 9 proof-term differences, and 2 new private lemmas. Direct imports of the original entry paths were checked by Lean.
Measurements
PR base
ec62f980b01d724d60cb0577e6ab9f9643fdbfb3. The matched pair used baseec62f980b01d724d60cb0577e6ab9f9643fdbfb3, Leanv4.36.0, and Mathlibfc4f59e577feb1a4956671bc04ac18aaaf8cd842. Each run removed the selected project's.lake/build/lib/leanand.lake/build/iroutputs and reused the pinned dependency artifacts. The target built 61 modules at base and 63 at head.Lake measured
Shadowat 44s → 34s. BaseExtensionsandTrianglestook 48s and 22s in sequence. At head,ExtensionMapstook 21s, thenExtensionsandTriangleProofstook 16s and 16s in parallel. TheTriangleswrapper took 794ms.Two earlier clean pairs at
a157db851b8d55765ffd95db8876c7ef6e73c9de, before spelling-only changes to the new private binders, measured 172.85 → 141.64 s and 178.08 → 158.83 s. Additional head rebuilds during higher load measured 179.11 s and 171.13 s. Wall time on the shared VM varies with other workloads.Validation
lake shakereported advisory import suggestions. The new branch dependencies useExtensionMapsdirectly, and the old public imports retain their exports.The project also passed the repository's axiom, option-backdoor, compiler-message, and project-card declaration checks for every selected module, plus the root and documentation toolchain and Mathlib pin checks. Local compiled validation covered the selected project. The whole-pool build runs in GitHub CI.