Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Add global expanded APK cache #133

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

jonjohnsonjr
Copy link
Contributor

This dedupes fetching and expansion of APKs to avoid simultaneous builds doing a lot of duplicate expensive work. As a bonus, we also deduplicate indexing an APK's tar headers so we do it once per APK per process instead of every time we open an APK.

The caching mechanisms that already existed are very useful for cache hits on subsequent builds, but there was still some overhead loading things from disk per cache hit. We avoid most of that now. There was also no coordination across builds when fetching indexes, keys, and APKs. Now, we should only fetch or load any given thing one time, which will reduce the number of requests we send out to the internet but also a lot of CPU in gunzip and untar.

This dedupes fetching and expansion of APKs to avoid simultaneous builds
doing a lot of duplicate expensive work. As a bonus, we also deduplicate
indexing an APK's tar headers so we do it once per APK per process
instead of every time we open an APK.

The caching mechanisms that already existed are very useful for cache
hits on subsequent builds, but there was still some overhead loading
things from disk per cache hit. We avoid most of that now. There was
also no coordination across builds when fetching indexes, keys, and
APKs. Now, we should only fetch or load any given thing one time, which
will reduce the number of requests we send out to the internet but also
a lot of CPU in gunzip and untar.

Signed-off-by: Jon Johnson <[email protected]>
@jonjohnsonjr
Copy link
Contributor Author

Tested all three new caches out with the terraform provider on a small set of chainguard-images:

terraform apply -auto-approve -target=module.go -target=module.jdk -target=module.jre

With a warm apko cache, this is not that significant because we spend so much time ing zip, but we do drop from 21s to 20s.

With a cold apko cache (which is what our CI will see), I I saw overall time drop from 36s to 27s.

Mostly, that's time not spent waiting on HTTP HEAD requests to come back.

Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

Nice

@imjasonh imjasonh merged commit cb033c6 into chainguard-dev:main Oct 10, 2023
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants