Lake: per-module `*.setup.json` lists every transitive import and dominates build output on large projects
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- json
- Ambito
- build-system
Direzione di ricerca
Start with the reproduction: a chain of 2,000 trivial modules where each .lake/build/ir/Chain/M<k>.setup.json has an importArts list with one entry per transitive import, so the total size grows quadratically. Look at how Lake writes this file and what the --setup consumer reads from it. Done means the setup file size stops scaling with the import closure, and the chain repro's total setup.json output is roughly proportional to the module count. Agreeing on the format change first is part of the work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release (4.38.0-nightly-2026-11-20, also v4.37.0-rc1).
- When reporting a perceived soundness bug: Does it affect
lake check --paranoid?
N/A: not a soundness report.
Description
For each module Lake writes .lake/build/ir/<Module>.setup.json, and its importArts field has one entry per transitive import, with absolute paths. So the file grows with the module's import closure, and the total over a project grows with modules x closure size.
Context
I noticed this building a 175,187-module project on v4.33.1 (https://alpo.ge/lean.tar.gz.part01 ... part14), where most modules import Mathlib. After lake build the setup files were 983 GiB against 88 GiB of .olean files.
On a small scale: a module that only does import Mathlib gets a 6.2 MB setup file on v4.36.0 (6.4 MB on v4.37.0-rc1), next to a 5 KB .olean.
Steps to Reproduce
- Build a chain of 2,000 trivial modules with no dependencies, where module k imports module k-1:
mkdir repro && cd repro
echo 'leanprover/lean4:nightly' > lean-toolchain
cat > lakefile.toml <<'EOF'
name = "repro"
defaultTargets = ["Chain"]
[[lean_lib]]
name = "Chain"
EOF
mkdir Chain
printf 'def c0001 : Nat := 1\n' > Chain/M0001.lean
for k in $(seq 2 2000); do
printf 'import Chain.M%04d\n\ndef c%04d : Nat := c%04d + 1\n' $((k-1)) $k $((k-1)) > $(printf 'Chain/M%04d.lean' $k)
done
echo 'import Chain.M2000' > Chain.lean
lake build
- Compare the setup files with the compiled modules:
ls -l .lake/build/ir/Chain/M2000.setup.json .lake/build/lib/lean/Chain/M2000.olean
du -cb .lake/build/ir/Chain/*.setup.json | tail -1
du -cb .lake/build/lib/lean/Chain/*.olean | tail -1
Expected behavior: build output roughly proportional to the compiled modules.
Actual behavior (nightly): each .olean is 5,976 bytes, while M2000.setup.json is 184,036 bytes (1,999 entries, about 92 bytes each). The total is quadratic in the chain length:
| First n modules | all setup.json |
all .olean |
|---|---|---|
| 500 | 11.5 MB | 3.0 MB |
| 1,000 | 46.1 MB | 6.0 MB |
| 2,000 | 184.2 MB | 12.0 MB |
v4.37.0-rc1 behaves the same.
Versions
Lean 4.38.0-nightly-2026-11-20 (commit 82bff16a3463) and 4.37.0-rc1, Lake 5.0.0, Ubuntu 24.04 x86-64. The large project was on v4.33.1.
Additional Information
I don't know the constraints on the --setup format. Things that might work: storing a shared closure's artifact map once and referencing it, listing only direct imports, or deleting the file once the module is built.
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16305 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
sync cache dist/imgAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
oleeskild/digitalgarden#435 ·
-
iyi test: parallel builds race fetching a module into a cold cache (Directory not empty)Forse già presa @sdogruyol l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
Tarektouati/made#186 ·
I maintainer di solito rispondono entro 1 giorno
-
Update SqlClient to 6.1.8Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
fluentmigrator/fluentmigrator#2463 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno