Skip to content

ci: cache the docbuild incremental state around API generation - #208

Merged
cameronfreer merged 3 commits into
masterfrom
ci/docbuild-cache
Sep 6, 2026
Merged

cameronfreer merged 3 commits into
masterfrom
ci/docbuild-cache

Conversation

@cameronfreer

@cameronfreer cameronfreer commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

Cache the nested docbuild/.lake/build around API generation, and guard the docbuild workspace against drifting from the root.

Why. Master pushes took 45–64 minutes against 6–7 for PRs, and the gap is lake build Graphon:docs in the docbuild workspace, whose incremental state lean-action never caches (it caches the root .lake only).

What.

  • actions/cache/restore of docbuild/.lake/build right after the sync guard and before lean-action, so the small docs entry is retrieved and its last-access time refreshed before the run saves another ~2.6 GB root cache (GitHub evicts by last access under the repository limit; a two-day-old docs entry was evicted between the first two dispatches, before this reordering). actions/cache/save immediately after successful generation, so a later TeX/Jekyll/Pages failure cannot discard a valid cache. Key docbuild-v1-<os>-<arch>-<hash of both toolchains, both manifests, both Lake configs>-<sha>; fallback prefix without the SHA restores the latest compatible prior state. Save only when the exact key was not already restored, using the restore step's cache-primary-key.
  • API generation also runs on workflow_dispatch so the cache can be exercised from a branch; assembly and deployment stay master-only.
  • scripts/check_docbuild_sync.py, run right after checkout: docbuild's toolchain and Mathlib must match the root's.

Measured on this branch (gh workflow run build.yml):

run docbuild cache API generation job
cold miss, saved ~18 min 40 min
same SHA exact hit 59 s 9m21s
new SHA, before early restore miss (prior entry evicted) ~18 min 51 min
new SHA, with early restore restored from the previous SHA's key via the prefix, saved under the new SHA 55 s 8m53s

Not included, deliberately: weekly docs split, committed lean_decls, docgen-action, exact doc-gen4 commit pin, apt caching, root-cache policy (the 2.6 GB per-SHA root caches lean-action saves on PR runs are the real storage pressure; separate change).

Post-merge master runs are the production check; the second master push is the decisive one.

doc-gen4's incremental state lives in docbuild/.lake, a separate Lake
workspace from the root .lake that lean-action caches, so every master push
regenerated the API docs from scratch — nearly the whole of the 45–64 minute
master runs against 6–7 minute PR runs.

Restore docbuild/.lake/build before `lake build Graphon:docs` and save it
immediately after successful generation, keyed by format version, OS,
architecture, both toolchains, both manifests, both Lake configurations,
and the exact commit, with a dependency-compatible fallback prefix that
restores the latest compatible prior state. The save reuses the restore
step's primary key and runs only when that key was not already restored.
API generation also runs on manual dispatch so the cache can be exercised
from a branch; assembly and deployment remain master-only.

Add scripts/check_docbuild_sync.py, run right after checkout: the nested
workspace must resolve the same toolchain and Mathlib as the root.
Retrieve the small docs entry, refreshing its last-access time, before this
run adds another large root cache; eviction is by last access under the
repository limit. Saving stays immediately after successful API generation.
@cameronfreer
cameronfreer merged commit 9f7be59 into master Sep 6, 2026
4 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