Skip to content

local cache: add lazy option to skip eager extraction on import#6573

Open
jirimoravcik wants to merge 1 commit intomoby:masterfrom
jirimoravcik:feat/add-lazy-to-local-cache-import
Open

local cache: add lazy option to skip eager extraction on import#6573
jirimoravcik wants to merge 1 commit intomoby:masterfrom
jirimoravcik:feat/add-lazy-to-local-cache-import

Conversation

@jirimoravcik
Copy link

When using --import-cache type=local with an ephemeral/daemonless buildkitd (one container per build), every build eagerly extracts all base image layers from the local cache — even when those layers are CACHED and don't need re-execution.

With a large base image like node:20 (~350MB, 8 layers), this adds 5–10 seconds to what should be a near-instant rebuild. I've thoroughly described this in #6572.

This PR fixes it by introducing lazy param to the local cache. If it's false - default, the behavior remains unchanged. If you set it to true, it will not perform "unlazying" on the layers, which improves the performance.

Closes #6572

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an opt-in lazy=true mode for --import-cache type=local to avoid eager “unlazying” (layer extraction) during cache import, improving rebuild performance for ephemeral/daemonless buildkitd setups.

Changes:

  • Add lazy attribute parsing to the local cache importer and use it to skip unlazyProvider wrapping.
  • Document the new lazy option in the buildctl reference and repository README.
  • Update getContentStore to optionally return the raw session-backed content store when lazy mode is enabled.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
docs/reference/buildctl.md Documents --import-cache type=local,...,lazy=true usage for buildctl.
cache/remotecache/local/local.go Implements lazy attribute to bypass eager unlazying by skipping unlazyProvider.
README.md Adds lazy=<true|false> to local cache import option docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add a lazy=true option to the local cache importer
(--import-cache type=local,src=...,lazy=true) that skips the
unlazyProvider wrapping. In ephemeral/daemonless buildkitd setups,
this avoids eagerly extracting all cached layers on every build.

Signed-off-by: Jiří Moravčík <jiri.moravcik@gmail.com>
@jirimoravcik jirimoravcik force-pushed the feat/add-lazy-to-local-cache-import branch from 223ef4d to 3021836 Compare March 15, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lazy param to the local cache import

2 participants