Repository navigation
Reduce peak memory in relation-algebra orbit replay - #1063
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 code issues were found in the replay optimization. SummaryAdds
No actionable issues were found. The reported memory reduction and declaration audit were not independently rerun. External upstream sources were not reverified; the patch changes neither the mathematical headlines nor their source claims. Reviews (1) · Last reviewed commit: "Reduce relation algebra orbit replay mem..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)
This build covers the changed modules and their dependency cones on top of the restored cache. The serial per-file sums below are useful for ranking slow files, not as a build budget. A base→head comparison was attempted but its measurements are unavailable (see the run log); modified files are omitted from the tables below. Statement changes✅ No statements changed — all 6,184 tracked declarations across 100 modified files kept their type; only proofs / definition bodies changed. Also: 99 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 (99)
Statements are compared textually against the merge base (comments and whitespace ignored; Total heartbeats: 3,219 maxHeartbeats units across 1 valid file (1,092 added LOC). Sum of Count-heartbeats wall-clock total: 2.01 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.FiniteIntegralRelationAlgebras.Cert.SegmentReplay |
3.50 s |
Per-file `lean --profile` output
LeanPool/FiniteIntegralRelationAlgebras/Cert/SegmentReplay.lean
import took 1.3s
cumulative profiling times:
attribute application 1.81ms
congr simp thm 0.244ms
declTypeLinter 6.21ms
dsimp 1.57ms
elaboration 56.8ms
fix level params 0.444ms
import 1.3s
initialization 39.6ms
instantiate metavars 1.41ms
interpretation 211ms
let-to-have transformation 0.173ms
linting 19.1ms
module linting 0.0437ms
parsing 14.3ms
process pre-definitions 5.31ms
share common exprs 2.95ms
simp 1.99ms
tactic execution 84ms
tacticAnalysis 5ms
type checking 12.9ms
typeclass inference 30.7ms
real 2.37
user 1.14
sys 0.89
Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.
Vilin97
left a comment
There was a problem hiding this comment.
Source review passed for b4e75bdfc5d413e7719ca7047a375041d20912ec.
- The new checker shares high-column bit matrices and stops comparisons when only the certified identity permutation can agree. The proof derives the original
checkSegUsingColumnsresult from the optimized Boolean check using the same group, size, and column certificates. The 99 replacements retain the original data and theorem statements and use kernel reduction to prove the new checks. - The reported clean-build pair used the exact PR base and measured 13.14% lower peak sampled anonymous compiler memory plus 27.6% lower summed module time for the rewritten certificates. The 6.1% whole-project wall-time improvement comes from a single pair on a shared VM. The declaration audit reported that all 121,163 existing records matched, including 3,870 exports. Measurements and declaration audit
- The hosted profiler measured the new shared checker. Its merge-base environment lacked that import when testing the rewritten files, so those files have no comparable hosted profile. Hosted profile
The required Lean build is still running. Lean Action CI
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | kernel replay optimization |
| Introduces tech debt | 🛑 yes |
| Maintainability | 🛑 regressed |
| Brittleness | 🛑 more_brittle |
| Risk | 🟡 medium |
Before merging, make the replay checker's input contract explicit and document how to preserve the optimization when regenerating certificates.
Findings (2)
- unchecked-precondition —
LeanPool/FiniteIntegralRelationAlgebras/Cert/SegmentReplay.lean:176
The public Boolean checker assumes that a remaining mask of1denotes the identity. With columns for a single swap of two bits, I verified in Lean thatcheckSegmentaccepts assignment 2 andcheckSegUsingColumnsrejects it. State the certified-column requirement oncheckSegmentitself and direct callers tocheckSegUsingColumns_of_checkSegment, which verifies the prerequisite for the current certificates. - regeneration-drift —
LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S4N1/C0/S214.lean:1585
The pinned generator still emitssegOKwith the original check. Regenerating the certificates can drop the replay edits and restore the higher-memory path while the certificates continue to pass. Record a pool-side recipe that reapplies the rewrite to the selected segments and explains why it retainsas_aux_lemma. Pinned certificate generator
Tokens: 2,510,135 in / 17,301 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $10.3001 (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.
Cut peak anonymous compiler memory for
FiniteIntegralRelationAlgebrasby 13.14% with a kernel-checked orbit replay.Changes
checkSegUsingColumns.S4N1and 22S2N2segments and adds their shared checker to the generated project index.The import CI recorded 43,950.1 seconds summed over 1,345 modules, with a 2.8 GiB compiler peak. On the VM, Lean's profiler recorded 22.2 seconds of type checking in
S239, and the original orbit-segment check took 7.19 seconds in a separate kernel profile. Import CI buildDeclaration audit
The baseline was
c0a34d020d4d0523e8be1a2b5b7f01e1c7c0ffdb. The optimized commit isb4e75bdfc5d413e7719ca7047a375041d20912ec. A Lean program read all project.oleanand.olean.privatedeclaration records before editing and after rebuilding. It compared names, exported visibility, declaration kinds, universe parameters, elaborated types, safety, reducibility, and all non-theorem bodies and recursor rules. Serialization omitted non-kernel expression metadata and theorem proof terms. The existing generated auxiliary theorem in each rewritten certificate is preserved byas_aux_lemma. A source comparison also verified that the existing certificate data and statement text are identical.All 121,163 pre-existing declarations matched, including all 3,870 exported records. There were zero removals or changed records. The 214 new declarations include the per-certificate theorems and the shared checker.
Measurements
Both clean project builds used the same Azure VM, Lean 4.36.0, Mathlib
fc4f59e577feb1a4956671bc04ac18aaaf8cd842, warm dependency artifacts, andLEAN_NUM_THREADS=5. I removed the selected project's compiled artifacts before each build. The repository watchdog sampledRssAnon + VmSwapabout once per second, and a scratch wrapper recorded all per-file peaks in bytes.S4N1/C0/S214)S4N1/C0/S169)S4N1/C0/S214went from 42 to 31 seconds and from 3,027,267,584 to 2,492,030,976 bytes. The memory metric is the largest sample for an individual Lean process. Wall time comes from one clean pair on a shared VM.Validation
The project declaration lint, text style, indexes, documentation workspace pin check, static quality scan, compiled-message audit, card declaration check, option audit, and axiom audit passed. The build-time check covered all 101 modified or added files. The slowest took 36 seconds and the new module peaked at 48,857,088 bytes of anonymous compiler memory. The targeted
lake shakerun suggested import additions in six untouched foundation and theory modules. The 101 files in this patch received no import suggestions.