Skip to content

Conversation

@twz123
Copy link
Member

@twz123 twz123 commented Oct 28, 2025

Description

The Go cache has fixed trim settings. It updates mtimes hourly and trims daily, deleting anything older than five days. This is too conservative for CI caches. We only want to retain caches used in the current run. We can achieve this by setting the mtime of all cache files to a time between one hour and five days ago. After the build, all used cache entries will have a newer mtime. Everything else can be trimmed.

Remove the caching of the Go module cache. It only provides an approximate 20-second speed boost, while eating up a couple of 100MB per GitHub cache. We can add it back later on if we think it's really worth it.

Simplify the caching of the embedded executables. Makes the cache size smaller, at the cost of some extra packaging time spent to build the gzipped blob during build time. This requires some tricks to tell make what needs to be built and what doesn't.

Only keep the most recent cache per branch. All caches ending in a hash will be pruned so that only the newest cache is retained on a per-branch and per-key-prefix basis.

Don't use leading slashes for URLs passed to the gh CLI. Leading slashes would otherwise trigger file path normalization in bash on Windows, which would render the URL fragment illegal.

Use a fixed source date epoch in unit tests to better leverage cache usage.

Trying to mitigate this:


k0s-cache-usage

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

The Go cache has fixed trim settings. It updates mtimes hourly and trims
daily, deleting anything older than five days. This is too conservative
for CI caches. We only want to retain caches used in the current run.

We can achieve this by setting the mtime of all cache files to a time
between one hour and five days ago. After the build, all used cache
entries will have a newer mtime. Everything else can be trimmed.

Signed-off-by: Tom Wieczorek <[email protected]>
It only provides an approximate 20-second speed boost, while eating up
a couple of 100MB per GitHub cache. We can add it back later on if we
think it's really worth it.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 force-pushed the optimize-actions-caches branch from 0b62d46 to 304dd78 Compare October 28, 2025 16:59
Simplify the caching of the embedded executables. Makes the cache size
smaller, at the cost of some extra packaging time spent to build the
gzipped blob during build time. This requires some tricks to tell make
what needs to be built and what doesn't.

Only keep the most recent cache per branch. All caches ending in a hash
will be pruned so that only the newest cache is retained on a per-branch
and per-key-prefix basis.

Don't use leading slashes for URLs passed to the gh CLI. Leading slashes
would otherwise trigger file path normalization in bash on Windows,
which would render the URL fragment illegal.

Use a fixed source date epoch in unit tests to better leverage cache
usage.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 force-pushed the optimize-actions-caches branch from 304dd78 to 8eb3ccd Compare October 28, 2025 17:00
@twz123 twz123 marked this pull request as ready for review October 28, 2025 19:32
@twz123 twz123 requested review from a team as code owners October 28, 2025 19:32
@twz123 twz123 requested review from jnummelin and ncopa October 28, 2025 19:32
@twz123 twz123 added area/ci chore backport/release-1.34 PR that needs to be backported/cherrypicked to the release-1.34 branch labels Oct 30, 2025
Copy link
Member

@jnummelin jnummelin left a comment

Choose a reason for hiding this comment

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

LGTM

@twz123 twz123 merged commit 4531721 into k0sproject:main Oct 31, 2025
309 of 325 checks passed
@twz123 twz123 deleted the optimize-actions-caches branch October 31, 2025 13:44
@k0s-bot
Copy link
Contributor

k0s-bot commented Oct 31, 2025

Successfully created backport PR for release-1.34:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci backport/release-1.34 PR that needs to be backported/cherrypicked to the release-1.34 branch chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants