Skip to content

refactor: make exportEntriesFnEx return all olean levels at once#13142

Merged
nomeata merged 3 commits intomasterfrom
joachim/exportEntriesFnEx
Mar 27, 2026
Merged

refactor: make exportEntriesFnEx return all olean levels at once#13142
nomeata merged 3 commits intomasterfrom
joachim/exportEntriesFnEx

Conversation

@nomeata
Copy link
Copy Markdown
Collaborator

@nomeata nomeata commented Mar 26, 2026

This PR replaces the per-level OLeanLevel → Array α return type of exportEntriesFnEx with a new OLeanEntries (Array α) structure that bundles exported, server, and private entries together. This allows extensions to share expensive computation across all three olean levels instead of being called three separate times.

A new computeExtEntries function in Environment.lean calls each extension's export function once and distributes results across levels. mkModuleData accepts optional pre-computed entries, and writeModule uses computeExtEntries to compute once for all three olean parts.

Extensions that previously relied on env.setExporting being pre-applied by mkModuleData now call env.setExporting true internally for their exported/server-level filtering, since the export function is called once rather than per-level.

Extracted from #13117 to be reviewed independently.

Replace the per-level `OLeanLevel → Array α` return type of
`exportEntriesFnEx` with a new `OLeanEntries (Array α)` structure
that bundles exported, server, and private entries together.

This allows extensions to share expensive computation across all
three olean levels instead of being called three separate times.
A new `computeExtEntries` function calls each extension's export
function once and distributes results across levels.

Extensions that previously relied on `env.setExporting` being
pre-applied by `mkModuleData` now call `env.setExporting true`
internally for their exported/server-level filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nomeata
Copy link
Copy Markdown
Collaborator Author

nomeata commented Mar 26, 2026

!radar

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 26, 2026

Benchmark results for 4f9f135 against 4786e08 are in. Significant changes detected! @nomeata

  • build//instructions: -106.1G (-0.88%)

Large changes (1✅)

  • build/profile/.olean serialization//wall-clock: -14s (-17.22%)

Medium changes (23✅)

Too many entries to display here. View the full report on radar instead.

Small changes (365✅, 3🟥)

Too many entries to display here. View the full report on radar instead.

@nomeata nomeata marked this pull request as ready for review March 26, 2026 19:58
@nomeata nomeata added the changelog-language Language features and metaprograms label Mar 26, 2026
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Mar 26, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented Mar 26, 2026

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-03-25 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-03-26 20:18:58)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 2bc7a778061470e46b4ac882845e8dca34f9550c --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-27 08:31:42)

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 26, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Mar 26, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 26, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Mar 26, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing bot commented Mar 26, 2026

Mathlib CI status (docs):

  • 💥 Mathlib branch lean-pr-testing-13142 build failed against this PR. (2026-03-26 20:26:23) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 2bc7a778061470e46b4ac882845e8dca34f9550c --onto 4786e082dca22873d14d2a5b9b7c8843380c6e78. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-27 08:31:41)

@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Mar 26, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@nomeata nomeata added this pull request to the merge queue Mar 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 27, 2026
@nomeata nomeata added this pull request to the merge queue Mar 27, 2026
Merged via the queue into master with commit 439c3c5 Mar 27, 2026
19 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Mar 27, 2026
This PR re-enables `#print axioms` under the module system by computing
axiom dependencies at olean serialization time. It reverts #8174 and
replaces it with a proper fix.

Depends on #13142, which refactors `exportEntriesFnEx` to return all
three olean levels at once via a new `OLeanEntries` structure, allowing
extensions to share expensive computation.

The axiom extension uses `exportEntriesFnEx` to walk bodies of all
public declarations in the current module, collecting axiom dependencies
in a single batch with a shared cache across declarations. The results
are stored sorted for binary search and exported uniformly to all olean
levels. Downstream modules look up pre-computed axiom data from imported
oleans, so axiom collection never crosses module boundaries. During
elaboration of the current module, `collectAxioms` walks bodies directly
since they are always available locally.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
volodeyka pushed a commit that referenced this pull request Apr 16, 2026
This PR re-enables `#print axioms` under the module system by computing
axiom dependencies at olean serialization time. It reverts #8174 and
replaces it with a proper fix.

Depends on #13142, which refactors `exportEntriesFnEx` to return all
three olean levels at once via a new `OLeanEntries` structure, allowing
extensions to share expensive computation.

The axiom extension uses `exportEntriesFnEx` to walk bodies of all
public declarations in the current module, collecting axiom dependencies
in a single batch with a shared cache across declarations. The results
are stored sorted for binary search and exported uniformly to all olean
levels. Downstream modules look up pre-computed axiom data from imported
oleans, so axiom collection never crosses module boundaries. During
elaboration of the current module, `collectAxioms` walks bodies directly
since they are always available locally.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants