8000 feat: lake: local artifact cache by tydeu · Pull Request #8922 · leanprover/lean4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: lake: local artifact cache #8922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 27, 2025
Merged

Conversation

tydeu
Copy link
Member
@tydeu tydeu commented Jun 22, 2025

This PR introduces a local artifact cache for Lake. When enabled, Lake will shared build artifacts (built files) across different instances of the same package using an input- and content-addressed cache.

To enable support for the local cache, packages must set enableArtifactCache := true in their package configuration. The reason for this is twofold. This feature is new and experimental, so it should be opt-in. Also, some packages may need to disable it as the cache entails that artifacts are no longer necessarily available within the build directory, which can break custom build scripts.

The cache location is determined by the system configuration. Lake's first preference is to store it under the Lean toolchain in a lake/cache directory. If Elan is not available, Lake will store it in common system location (e.g., $XDG_CACHE_HOME/lake, or ~/.cache/lake). On an exotic system where neither of these exist, the cache will be disabled. Users can override this location through the LAKE_CACHE_DIR environment variable. If set to empty, caching will be disabled.

The cache is both input and content-addressed. Mappings from input hash to output content hash(es) are stored in a per-package JSON Lines file (e.g., <cache-dir>/inputs/<pkg-name>.jsonl). Thus, mappings are shared across different instances of a package, but not between packages. The output content hashes are also now stored in trace files in a new outputs field. The value of this field can be either a single hash or an object of multiple content hashes for targets which produce multiple artifacts (e.g., Lean module builds). Separately, artifacts are stored in a single flat content-addressed cache (e.g., <cache-dir>/artifacts/<hash>.art. Artifacts are therefore shared across all cache-enabled packages.

Module *.olean and and *.ilean artifacts are cached. However, each package will still copy the files to their build directory, as Lean and the server currently expect them to be at a specific path. This will be changed for *.olean files when the performance issues with pre-resolving modules in Lake for lean --setup are solved.

@tydeu tydeu added the changelog-lake Lake label Jun 22, 2025
@tydeu tydeu force-pushed the lake/artifact-cache branch from c8af5af to 4b684a8 Compare June 22, 2025 03:45
@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 Jun 22, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 22, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 22, 2025
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jun 22, 2025
@leanprover-community-bot
Copy link
Collaborator
leanprover-community-bot commented Jun 22, 2025

Mathlib CI status (docs):

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 22, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 22, 2025
@tydeu
Copy link
Member Author
tydeu commented Jun 22, 2025

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 9c75dfa.
There were significant changes against commit db499e9:

  Benchmark          Metric       Change
  ================================================
+ nat_repr           task-clock   -12.7% (-27.4 σ)
+ nat_repr           wall-clock   -12.7% (-26.5 σ)
- workspaceSymbols   task-clock     4.8%  (33.3 σ)
- workspaceSymbols   wall-clock     4.8%  (34.2 σ)

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 25, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jun 25, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 26, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jun 26, 2025
@tydeu tydeu force-pushed the lake/artifact-cache branch from 7f679ce to 6f6c053 Compare June 27, 2025 01:56
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 27, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jun 27, 2025
@tydeu
Copy link
Member Author
tydeu commented Jun 27, 2025

!bench

@tydeu tydeu added the release-ci Enable all CI checks for a PR, like is done for releases label Jun 27, 2025
@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 6f6c053.
There were significant changes against commit d3dda9f:

  Benchmark          Metric        Change
  =================================================
- stdlib             grind           1.0%  (24.9 σ)
- stdlib             grind canon     1.6% (429.2 σ)
- stdlib             wall-clock      6.2%  (66.3 σ)
- workspaceSymbols   task-clock      2.2%  (28.5 σ)
- workspaceSymbols   wall-clock      2.2%  (25.4 σ)

@tydeu tydeu removed the release-ci Enable all CI checks for a PR, like is done for releases label Jun 27, 2025
@tydeu tydeu force-pushed the lake/artifact-cache branch from 06c57c0 to b5de358 Compare June 27, 2025 03:38
@tydeu tydeu marked this pull request as ready for review June 27, 2025 03:38
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 27, 2025
@tydeu tydeu added this pull request to the merge queue Jun 27, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jun 27, 2025
Merged via the queue into leanprover:master with commit 541ff1e Jun 27, 2025
21 checks passed
@tydeu tydeu deleted the lake/artifact-cache branch June 27, 2025 05:27
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-lake Lake 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.

3 participants
0