Skip to content

Speed up convex-octagon coverage certificate replay - #1027

Merged
Vilin97 merged 1 commit into
mainfrom
fix/convex-octagon-replay-20261126
Nov 26, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
fix/convex-octagon-replay-20261126

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Ready for review. The convex-octagon coverage certificates use a faster kernel replay with an equality proof back to the original checker.

Scope

The published Lean Pool profile attributes 438.31 of the project's 638.44 source seconds to 94 coverage-fact modules. Those modules contain 375 node-chunk checks with a common checker. The project source matches the profiled revision. Lean Pool source profile

  • Grouped table accesses use single-pass list lookups during kernel reduction. Sparse word lookup scans the witness list directly.
  • Pruning and transition replay share the node lookup and bounds guards. Rejection replay counts column bits directly in the packed prefix.
  • The new replay is proved equal to nodeClaimChunkValidB for arbitrary claims, starts, and counts. The fact modules register its decidability proof locally and retain their existing decide +kernel scripts.

Declaration audit

Base 34701e7c7dd46632161dafc475b2a80bccd6511a.

I exported compressed manifests from Lean's private and exported environments. The comparison covered module membership, names, visibility, exact kernel types and universe parameters, declaration kind and safety, reducibility metadata, recursor rules, and exact non-proof bodies. It compared structural expressions with elaborator metadata removed.

All 4,120 base records covering 4,094 distinct names matched on those fields. The 375 changed proof bodies belong to the existing private decide auxiliaries. The replay module accounts for all 126 added records, including three identical additional realizations of existing equation theorems. The existing source files differ only in the replay import and local instance registration, plus the generated import index.

Measurements

Lean 4.36.0 and Mathlib fc4f59e577feb1a4956671bc04ac18aaaf8cd842. Every timing rebuilt the complete project with pinned dependencies and the compiler plugin already built.

LEAN_NUM_THREADS=4 LAKE_ARTIFACT_CACHE=false \
  /usr/bin/time -f 'wall=%e user=%U sys=%S maxrss_kib=%M' \
  lake --no-ansi --wfail build LeanPool.Erdos97ConvexOctagon.Imports
Clean build Wall (s) User + system CPU (s) Peak process RSS (KiB)
Base, paired 620.32 1,588.67 1,703,448
Head, paired 548.48 1,316.82 1,622,736
Base, sequential 1 313.02 1,304.55 1,687,156
Base, sequential 2 360.97 1,471.51 1,691,968
Head, sequential 1 339.50 1,294.11 1,619,336
Head, sequential 2 368.13 1,291.90 1,620,628

The paired builds started together on the same Azure VM. Each had one logical CPU per physical core, with base pinned to odd CPU IDs and head to even CPU IDs. The paired wall time fell 11.58%, build CPU time fell 17.11%, and summed times for the 94 coverage-fact modules fell 31.51% (1,207.70 s to 827.10 s). Lean's declaration profiler measured 2.22 s to 1.06 s of kernel checking for nodeClaimChunkValidB branchClaims6Row15 0 64 = true in a representative scratch probe.

The sequential runs show the effect of varying VM load on elapsed time. The paired result is one comparison with warm dependency artifacts and the VM's concurrent workload.

Validation

  • Warning-free complete project builds and silent compiler logs for all 269 modules.
  • lake env lean --run scripts/ci/lint-project.lean <all project modules> passed for 4,217 declarations.
  • lake exe lint-style LeanPool.Erdos97ConvexOctagon.Imports and lake exe mk_all --module --check passed.
  • uv run --locked --project python python -m lean_pool.quality --repo . --static-only passed. The same checker passed the project's main-declaration resolution, allowed-axiom audit, environment audit, and build-log audit.
  • lake shake --force --keep-public LeanPool.Erdos97ConvexOctagon.Imports reported advisory suggestions in existing files outside the diff. The replay files and their imports received no suggestions.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

No actionable defect was found in the replay or its integration.RetriggerView in Greptile

[Medium impact] No actionable defect was found in the replay or its integration.

Summary

Adds a faster coverage-certificate replay while keeping the existing checker and theorem statements.

  • Coverage facts replay node chunks with less kernel work.

Reviewed the supplied changes, original checker, project card, entry modules, and repository guidance. External source and provenance claims were not independently verified. The reported build timings and declaration audit were not rerun.

Reviews (1) · Last reviewed commit: "Speed up convex-octagon coverage certifi..." · Reviewed by Greptile

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accept the replay change at commit af6a6e5, pending required CI.

  • The equality proof covers arbitrary claims, starts and counts. The local decidability instance transports the faster Boolean replay back to the existing predicate. I verified that all 94 fact modules and their 375 chunk checks are byte-identical after removing the new import and local instance registration.
  • The paired measurements show 17.11% less CPU time and 31.51% less summed compile time in the coverage modules. Sequential wall times varied with machine load. The CPU and module measurements support the change.
  • The patch passes the whitespace check and combines cleanly with current main. Lean CI and Proof Profile were still running at review.

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

lake build wall time (changed modules): 28.46 s (= 0.47 min) — user 6.74 s, sys 2.65 s.

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 620 tracked declarations across 95 modified files kept their type; only proofs / definition bodies changed.

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.

Total heartbeats: 8,608 maxHeartbeats units across 1 valid file (629 added LOC).

Sum of lean --profile: 1708.3 ms (= 1.71 s) across 1 valid file. Import-excluded time: 947.3 ms (= 0.95 s).

Count-heartbeats wall-clock total: 2.16 s. Repeated import cost inside lean --profile: 761.0 ms (= 0.76 s).

Heartbeat values sum disjoint root command traces with trace.profiler.useHeartbeats and synchronous elaboration, converted from raw allocations to maxHeartbeats units by dividing by 1000. They include command elaboration and kernel checking, exclude imports, and include profiler overhead; they are not comparable to the deprecated linter's totals. Per-file wall clocks are measured under parallel load and are noisier than heartbeats.

LOC counts added lines in the profiled Lean files from this PR diff.

File LOC Heartbeats (maxHB) Count wall (s) lean --profile (s) Without import (s) Import (s) Commands Errors
LeanPool/Erdos97ConvexOctagon/CoverageCertificateReplay.lean 346 8,608 2.16 1.71 0.95 0.76 45 0
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts00.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts01.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts02.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts03.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts04.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts05.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts06.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts07.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts08.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts09.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts10.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts11.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts12.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts13.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts14.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts15.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts16.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts17.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts18.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts19.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts20.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts21.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts22.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts23.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts24.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts25.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts26.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts27.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts28.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts29.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts30.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts31.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts32.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts33.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts34.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts35.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts36.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts37.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts38.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts39.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts40.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts41.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts42.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts43.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts44.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts45.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts46.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts47.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts48.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts49.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts50.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts51.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts52.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts53.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts54.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts55.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts56.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts57.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts58.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts59.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts60.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts61.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts62.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts63.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts64.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts65.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts66.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts67.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts68.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts69.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts70.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts71.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts72.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts73.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts74.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts75.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts76.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts77.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts78.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts79.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts80.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts81.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts82.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts83.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts84.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts85.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts86.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts87.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts88.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts89.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts90.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts91.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts92.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts93.lean 3 — — — — — 0 1
LeanPool/Erdos97ConvexOctagon/Imports.lean 1 — — — — — 0 1
Total 629 8,608 2.16 1.71 0.95 0.76 45 95

Aggregate phase totals

Phase Time
import 761.0 ms (= 0.76 s)
tactic execution 227.0 ms (= 0.23 s)
interpretation 187.0 ms (= 0.19 s)
simp 132.0 ms (= 0.13 s)
elaboration 95.8 ms (= 0.10 s)
typeclass inference 71.4 ms (= 0.07 s)
type checking 55.9 ms (= 0.06 s)
initialization 37.2 ms (= 0.04 s)
linting 25.8 ms (= 0.03 s)
compilation (LCNF base) 24.1 ms (= 0.02 s)
compilation (LCNF mono) 15.6 ms (= 0.02 s)
parsing 15.5 ms (= 0.02 s)

Slowest changed modules (from lake build)

Changed module Lake time
LeanPool.Erdos97ConvexOctagon.CoverageCertificateReplay 2.40 s
Per-file `lean --profile` output

LeanPool/Erdos97ConvexOctagon/CoverageCertificateReplay.lean

import took 761ms
cumulative profiling times:
	attribute application 0.363ms
	compilation (IR) 2.11ms
	compilation (LCNF base) 24.1ms
	compilation (LCNF impure) 9.93ms
	compilation (LCNF mono) 15.6ms
	congr simp thm 5.77ms
	declTypeLinter 8.85ms
	elaboration 95.8ms
	fix level params 1.09ms
	import 761ms
	initialization 37.2ms
	instantiate metavars 2.07ms
	interpretation 187ms
	let-to-have transformation 1.83ms
	linting 25.8ms
	module linting 0.0183ms
	parsing 15.5ms
	process pre-definitions 14.2ms
	share common exprs 6.91ms
	simp 132ms
	tactic execution 227ms
	tacticAnalysis 6.9ms
	type checking 55.9ms
	typeclass inference 71.4ms
real 1.65
user 1.42
sys 0.47

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

@Vilin97

Vilin97 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 LLM review — refactor (gpt-6.2-sol)

Reviewed head: af6a6e5c9622ebd8dc89de2f33795ca3d03020fa

Verdict: 🛑 request_changes

The refactor adds a kernel replay that uses list lookups and packed column counts, proves it equivalent to the original checker, and selects it through local instances in the coverage-fact modules. I built three affected fact modules and measured median kernel checking time of 1.55 s with the original checker and 0.71 s with replay on the representative 64-node chunk. The whole-project timings are contributor measurements.

Aspect Value
Scope kernel replay optimization
Introduces tech debt 🛑 yes
Maintainability 🛑 regressed
Brittleness 🛑 more_brittle
Risk 🟡 medium

Keep the measured speedup by sharing the unchanged validation rules and making the chunk proofs select the replay explicitly.

Findings (2)

  • duplicated-checker — LeanPool/Erdos97ConvexOctagon/CoverageCertificateReplay.lean:291
    The replay copies all six row-partition guards from nodePruningValidB, and replayActiveRow copies the child-state checks from processRow. Those rules are independent of the faster lookups. The equality proofs catch inconsistent edits at build time, while maintainers still have to change both implementations. Extract shared Boolean predicates for the partition and child-state checks, then rerun the chunk timing to verify the speedup.
  • silent-performance-fallback — LeanPool/Erdos97ConvexOctagon/CoverageCertificateFacts80.lean:21
    Each fact module must register the faster instance to get the speedup. In the timing probe, omitting the registration still let decide +kernel succeed with the standard Boolean instance, so a new or regenerated fact module can silently fall back to the slower checker. Use a shared chunk-proof tactic that passes nodeChunkReplayDecidable explicitly so losing the replay becomes a build error.

Tokens: 1,905,318 in / 13,543 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $7.8244 (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.

@Vilin97
Vilin97 added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit a87d484 Nov 26, 2026
29 checks passed
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