-
-
Notifications
You must be signed in to change notification settings - Fork 19
Disk cache garbage collection #71
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
base: main
Are you sure you want to change the base?
Disk cache garbage collection #71
Conversation
|
I am seeing some odd errors, like: I don't actually have conflicting jobs (as far as I can tell), so not sure what's going on. |
ecb896b to
da63002
Compare
|
It turns out, according to actions/toolkit#658, you can't actually update an existing key. The only option is creating a new key, so I add a unique identifier to the end, and restore it via a prefix match. |
da63002 to
86393ef
Compare
|
@calebzulawski please ping me for review/testing once you're happy with implementation |
97ff4e6 to
abe9708
Compare
abe9708 to
7c87da9
Compare
9ccdefd to
ce74503
Compare
|
@p0deje sorry for all the churn, I can clean up the history if you'd like, but I think this is good to go. A quick summary of changes:
|
bf0234d to
f0a9aff
Compare
f0a9aff to
6f5d038
Compare
|
|
||
| const bazeliskVersion = core.getInput('bazelisk-version') | ||
| const cachePrefix = core.getInput('cache-prefix') | ||
| const cacheVersion = core.getInput('cache-version') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we can drop this input and move it to cache-prefix instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this input? If the prefix is user-configurable, is it necessary at all? Should the default still have 1 in it?
config.js
Outdated
| `${moduleRoot}/WORKSPACE.bzlmod`, | ||
| `${moduleRoot}/WORKSPACE` | ||
| ] | ||
| const repositoryCacheEnabled = core.getBooleanInput('repository-cache') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a core.warning when repository-cache is not a boolean. This would indicate that an old interface for using repository-cache with a path to a file is being used, and we can add a link to the release page with upgrade instructions (https://github.com/bazel-contrib/setup-bazel/releases/tag/0.15.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding a core.error, because ultimately the action will fail
| const maxDiskCacheSize = core.getInput('max-disk-cache-size') | ||
| if (diskCacheEnabled) { | ||
| bazelrc.push(`common --disk_cache=${bazelDisk}`) | ||
| if (diskCacheName !== 'true') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a core.warning when disk-cache is not a boolean. This would indicate that an old interface for using disk-cache with a cache name is being used, and we can add a link to the release page with upgrade instructions (https://github.com/bazel-contrib/setup-bazel/releases/tag/0.15.0)
| required: false | ||
| default: "" | ||
| cache-prefix: | ||
| description: Key prefix for all caches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's clarify it's only used for disk/repository cache, not bazlisk/external.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I implemented it, all of the caches use this prefix, including bazelisk and external. This resolves #73
|
After trying to use it in Selenium (SeleniumHQ/selenium#15427), I believe we might need to separate inputs for prefixes for repository and disk caches. The main reason is that I see lots of similar repository caches for matrix jobs, and the Selenium project would benefit from having a single repository cache (GC'ed) while keeping disk caches separate for each job. |
|
We could do that, but on cache misses you will continue to see the kinds of errors in #73, as each job tries to write the same cache. Alternatively, if they aren't actually completely identical caches (e.g. the jobs have slightly different use of dependencies), whichever job completes last will win out for the next run and might end up missing some of the dependencies. You could even end up with a dependency repeatedly purged because the job that completes last doesn't use it and doesn't update its mtime. What about adding an input for additional restore prefixes, so those jobs could share caches rather than have a cache miss? |
|
@calebzulawski Sorry for the delay, it's been a crazy couple of months and I couldn't keep up with all the OSS projects I have on me. I'll go through our conversation and PR again to see where we left off. |
|
No worries, thanks! |
My initial implementation of garbage collection for #18. It seems to work but it could use more testing.