Skip to content

Commit 97ec249

Browse files
committed
CI: parallelize docs build with xargs -P 4; revert :docs facet (cascades into Mathlib) (0.230.62)
1 parent fb36034 commit 97ec249

2 files changed

Lines changed: 67 additions & 11 deletions

File tree

.github/workflows/docs.yml

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,57 @@ jobs:
5555

5656
- name: Build documentation (Linglib only, skip Mathlib)
5757
run: |
58-
# Use Lake's docs facet directly. `library_facet docs` (defined
59-
# in doc-gen4) only documents Linglib's own modules; transitive
60-
# Mathlib oleans are loaded into memory for symbol resolution
61-
# but not documented. Lake parallelizes per-module `docInfo`
62-
# jobs natively. `-j 2` caps concurrency to keep memory under
63-
# the 16 GB runner limit (each docInfo job loads the module's
64-
# full Mathlib import closure into memory).
65-
#
66-
# Stale DB cleanup: doc-gen4 schema changes across versions
58+
# Use doc-gen4 CLI directly. The Lake `:docs` facet cascades
59+
# docInfo jobs into Mathlib (~2700+ targets for any Linglib
60+
# module that imports mathlib), which OOMs the runner. The
61+
# CLI's `single` only writes docs for the named module — its
62+
# imports are loaded into memory but not documented.
63+
lake build doc-gen4
64+
65+
BUILD=.lake/build
66+
DOCGEN="lake exe doc-gen4"
67+
REPO_URL="https://github.com/${{ github.repository }}"
68+
COMMIT="${{ github.sha }}"
69+
SRC_URI="$REPO_URL/blob/$COMMIT"
70+
DB=api-docs.db
71+
export BUILD DOCGEN SRC_URI DB
72+
73+
# Remove stale DB — schema changes across doc-gen4 versions
6774
# cause "no such table" errors if an old DB is reused.
68-
rm -f .lake/build/api-docs.db api-docs.db
69-
lake -j 2 build Linglib:docs
75+
rm -f "$BUILD/$DB" "$DB"
76+
77+
# Bibliography prepass
78+
if [ -f docs/references.bib ]; then
79+
$DOCGEN bibPrepass --build "$BUILD" docs/references.bib
80+
elif [ -f docs/references.json ]; then
81+
$DOCGEN bibPrepass --build "$BUILD" --json docs/references.json
82+
else
83+
$DOCGEN bibPrepass --build "$BUILD" --none
84+
fi
85+
86+
# Document root module (may fail if Linglib.olean missing — non-fatal)
87+
$DOCGEN single --build "$BUILD" Linglib "$DB" "$SRC_URI/Linglib.lean" || true
88+
89+
# Document all Linglib submodules in parallel (-P 4 cores).
90+
# Each invocation writes to a shared SQLite db with WAL +
91+
# 24h busy timeout (see doc-gen4/Main.lean:walCheckpoint),
92+
# and updateModuleDb uses immediate transactions per
93+
# 100-module batch, so concurrent writers are safe.
94+
# Memory: each `single` peaks ~3-4 GB (mathlib import closure);
95+
# 4 in parallel ≈ 12-16 GB on a 16 GB runner. If we OOM,
96+
# drop -P to 2.
97+
find Linglib -name '*.lean' | sort | \
98+
xargs -I{} -P 4 sh -c '
99+
f="$1"
100+
mod=$(echo "$f" | sed "s|/|.|g; s|\.lean$||")
101+
echo " doc: $mod"
102+
$DOCGEN single --build "$BUILD" "$mod" "$DB" "$SRC_URI/$f" || true
103+
' _ {}
104+
105+
# Generate HTML + search index from database
106+
# NOTE: fromDb treats the db arg as a literal path (not relative
107+
# to --build), unlike single/genCore which prepend --build.
108+
$DOCGEN fromDb --build "$BUILD" "$BUILD/$DB"
70109
71110
- name: Install Hugo
72111
uses: peaceiris/actions-hugo@v3

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ The release clock (`v4.29.1`, ...) tracks Lean/mathlib compatibility and is what
44

55
## [Unreleased]
66

7+
## [0.230.62] - 2026-04-20
8+
9+
### Changed
10+
- **`.github/workflows/docs.yml`**: revert the docs build to the
11+
doc-gen4 CLI loop (`lake exe doc-gen4 single` per module) but
12+
parallelize it with `xargs -I{} -P 4`. The intervening
13+
"simplification" to `lake -j 2 build Linglib:docs` was empirically
14+
verified to cascade `module_facet docInfo` jobs through the import
15+
graph — building docs for a single Linglib module triggered ~2700
16+
Mathlib `docInfo` targets, which OOMs the 16 GB runner. The CLI's
17+
`single` only writes docs for the named module (imports load into
18+
memory but are not documented). With `-P 4` the doc step drops
19+
from ~95 min serial to ~25 min, total CI run ~66 min, well under
20+
the 2 h cap. doc-gen4's SQLite layer uses WAL + 30-min busy
21+
timeout for exactly this multi-writer scenario (mathlib's own docs
22+
build is the canonical case), so concurrent writes are safe.
23+
724
## [0.230.61] - 2026-04-20
825

926
### Changed

0 commit comments

Comments
 (0)