pack icon indicating copy to clipboard operation
pack copied to clipboard

Local Layer Cache

Open ekcasey opened this issue 4 years ago • 3 comments

Description

Operations like pack rebase and pack create-builder can be very slow when using the docker daemon. This happens because layers must be exported from docker and then loaded back in to create new images.

Proposed solution

This could be a lot faster if pack kept a layer cache on the host filesystem. Then, images would only need to read from the docker daemon if there was a cache-miss on the desired layer. This would be similar to how the launch-cache works in the lifecycle.

For example, if I am rebasing an image with 10 layers, 6 of which are run image layers the following happens

  1. The old app image is saved from docker
  2. A new image is loaded into the daemon containing layers from the new run-image + the 4 app specific layers from disk

Step 1 can be very slow, especially if the stack has a large base image.

If pack had a layer cache and that layer cache already contained the app layers (from a previous rebase, for example) we could skip the first step and proceed directly to step 2.

create-builder could be sped up for similar reasons. If I am creating a builder from a series of daemon image build packages pack currently saves every buidpack to disk before creating (loading) the builder. With a layer cache, pack wouldn't need to waste time saving buildpacks that it had used before.

Describe alternatives you've considered

  1. Drop support for the daemon ;)
  2. Deal with it

Additional context

Lifecycle uses a CachingImage to produce behavior similar to what is describe above without changing the image creation code. However, this shouldn't be used directly because it cleans up unused layers after each build. pack would probably want to allow the cache to grow forever (and provide an easy way to prune it).

ekcasey avatar Oct 01 '20 21:10 ekcasey

I'm honestly a little lost on the term cache given there are various caching layers in place. I wonder if a formal RFC for this proposal would provide some clarity and better format for discussion.

jromero avatar Mar 05 '21 17:03 jromero

Just checking to see if RFC was submitted for this request?

shresthaujjwal avatar Jan 25 '22 11:01 shresthaujjwal

@shresthaujjwal I don't believe so...

natalieparellano avatar Mar 04 '22 15:03 natalieparellano