Skip to content

Reduce Erdos97ConvexOctagon peak compiler memory - #717

Open
Vilin97 wants to merge 1 commit into
mainfrom
vilin/optimize-erdos97-20261024
Open

Vilin97 wants to merge 1 commit into
mainfrom
vilin/optimize-erdos97-20261024

Conversation

@Vilin97

@Vilin97 Vilin97 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Three finite-table audits in Erdos97ConvexOctagon build large kernel reduction caches. Check each of the eight centres independently in 24 private helper theorems, then assemble the existing public results by explicit finite case analysis. The full project build's maximum compiler RSS falls 31.33%. This is a memory optimization; full-build wall time is essentially unchanged.

The selected project has 268 source modules and approximately 5 MB of Lean, including 94 certificate-fact shards. Baseline sampling identified CoveragePairRowIndexMaskSoundness as its largest compiler process. That module's sampled peak falls from 2,476,996 to 1,401,652 KiB (43.41%). The pass also bounds the independent legal-row enumeration and pair-mask audits in CoverageSearchRowChoiceSoundness.

Only two existing project files change: three theorem proof bodies and 24 new private helper theorems. as_aux_lemma preserves the original generated auxiliary declarations. Existing statements, definitions, public names, imports, namespaces, notation, metadata, project cards, indexes and toolchain pins are unchanged.

Controlled full-project build Base Proposed
Wall time (seconds) 441.18 442.52
User CPU (seconds) 1374.09 1373.48
System CPU (seconds) 127.88 126.94
Maximum compiler RSS (KiB; GNU time) 2,476,544 1,700,752
Sampled aggregate concurrent compiler RSS (KiB) 6,529,292 6,497,876

Both timed runs used LEAN_NUM_THREADS=4, shared already-built pinned dependencies, and removed only this isolated worktree's selected-project Lean/IR artifacts before running:

/usr/bin/time -v lake --no-cache --wfail build +LeanPool.Erdos97ConvexOctagon.Imports:leanArts

The 31.33% result is GNU time's maximum RSS of an individual compiler process across the complete project build. Sampled aggregate concurrent compiler memory improved only 0.48%, and wall time increased 0.30%; no aggregate-memory or build-speed improvement is claimed. This VM also runs unrelated jobs. Initial uncontrolled-concurrency baseline wall time was 329.12 seconds and is excluded from the controlled comparison.

Compatibility audit: before editing, a standalone Lean program imported the base environment with extensions disabled and enumerated every constant owned by every project module through Environment.header.moduleData.constNames. It recorded public/private/generated names, owning module, declaration kind, exact elaborated type, universe parameters, safety, and exact non-theorem values. Full serialized expression records are retained; SHA-256 digests are used for comparison. After the optimized full build, all 4,066 original constants match exactly in every audited field. There are no missing declarations and no changed records, including generated private auxiliaries. The 48 additions are safe private theorem constants: 24 explicit helpers plus their kernel auxiliaries. A separate source audit recovers both original files byte-for-byte after reversing only these three proof-body rewrites and removing the new helper blocks.

Validation passed:

  • Complete selected-project build, with warnings treated as errors; zero warnings/errors.
  • Repository slow Mathlib/Batteries declaration linters: all 268 owned modules, 4,114 declarations, via lake env lean --run scripts/ci/lint-project.lean <all project modules>.
  • lake exe lint-style LeanPool.Erdos97ConvexOctagon.Imports.
  • Unchanged repository static quality routines on a complete selected-project inventory and card, using python -m lean_pool.quality --repo <project inventory> --static-only.
  • Unchanged repository axiom, option/backdoor, card and main-declaration checks for the selected project.
  • Additional whole-environment dependency walk: 4,114 owned declarations, 35,511 reachable constants, only Quot.sound, Classical.choice, and propext. The three pre-existing compiler-generated partial auxiliaries match the base exactly; no unsafe/partial declarations or axioms are added.
  • lake exe mk_all --module --check; no generated changes needed.
  • Full declaration manifest comparison, source audit, and git diff --check.
  • lake shake --keep-public --explain was investigated; imports with reported dependencies were retained. A scratch cbv trial exceeded its step limit and was discarded without raising limits or adding waivers.

Base: edbe5bd56f476cc2965564676b66199f281ab714. Head: 6404adb824fdf9c6a3300fcf44d66e18e76c8c96. Uses current main's pinned Lean/Mathlib 4.35.0-rc3, unchanged. Whole-pool hosted validation and independent refactor review remain required. This PR is left open with auto-merge disabled; no merge or queue action is requested.

Raw measurements, full compressed declaration records, manifests, and audit tools are retained on the Azure VM in /data/codex/scratch/vilin/optimization-erdos97-20261024T1617/.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict.

RetriggerView in Greptile

[Low impact] No blocking code issue was found in this proof-only refactor.

Summary

Splits three finite-table proofs into 24 private helpers, then joins their results with exhaustive cases on Vertex.

  • Legal-row checks now prove completeness one centre at a time.
  • Row-to-pair-mask checks now run separately for each centre.
  • Pair-table bits are checked in separate proofs for each centre.

Reviews (1) · Last reviewed commit: "Reduce Erdos97ConvexOctagon peak compile..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

Statement changes

✅ No statements changed — all 44 tracked declarations across 2 modified files kept their type; only proofs / definition bodies changed.

Also: 24 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 (24)
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_0 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_1 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_2 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_3 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_4 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_5 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_6 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.pairRowIndexMasks_bit_centre_7 — LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_0 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_1 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_2 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_3 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_4 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_5 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_6 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoiceAt_pairMask_centre_7 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_0 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_1 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_2 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_3 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_4 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_5 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_6 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean
  • Erdos97Octagon.RawIncidence.searchRowChoices_complete_centre_7 — LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean

Statements are compared textually against the merge base (comments and whitespace ignored; by proof terms embedded in a type are treated as proof-irrelevant), the same method as physlib's /check-golf. Anonymous instances and examples are not tracked.

Compile cost of modified files — base → head

Heartbeats: 73,961 → 79,129 (+5,168, +7.0%). Commands: 30 → 54.

Per-file wall sum: 29.5 s → 19.5 s (-34.0%). 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 trace.profiler.useHeartbeats and synchronous elaboration, converted to maxHeartbeats units. Failed measurements are not classified as cheaper or costlier. Δ lines counts added/deleted lines from this PR diff.

File Δ lines HB base HB head Δ HB Δ HB % Wall base (s) Wall head (s)
LeanPool/Erdos97ConvexOctagon/CoverageSearchRowChoiceSoundness.lean +120/-2 30,926 34,742 +3,816 +12.3% 12.71 8.56
LeanPool/Erdos97ConvexOctagon/CoveragePairRowIndexMaskSoundness.lean +60/-1 43,035 44,387 +1,352 +3.1% 16.76 10.90
Total +180/-3 73,961 79,129 +5,168 +7.0% 29.5 19.5

Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant