-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Cache keys #12
Comments
Thanks for raising this issue! I've actually been thinking about cache keys too, lately. We don't want the cache to be strict to the point of hashing the entire module and its source code, because then changing a single line would presumably result in an entirely separate cache key. Really, the reason to not use a single cache key is so that we can store multiple "versions" of the cache in parallel. Right now we do one per OS, and one per go.sum content. This was originally copied from the official docs. I'm actually not sure that splitting the caches per OS is really necessary, because hopefully the cache behaves exactly the same across OSs and filesystems. I'm also not entirely sure that including go.sum helps that much, because in general small variations in a go.sum should not result in a wildly different cache content (module download cache and/or build cache) that benefits from being stored separately. Something to note is that |
It's occurring to me that maybe |
Yeah, I don't believe go.sum files inside the cache are part of the key. It would be confusing for the cache value to be part of its cache key. Reusing inexact cache keys is already in place, for what it's worth. So we already do share slightly different go.sum caches anyway. The difference, I think, is how wasteful we want to be with GitHub's cache space allowance. If we store one cache entry per go.sum hash, we'll end up with more cache entries, getting closer to the 5GiB total limit at some point and causing evictions. On the other hand, using less specific cache keys (such as just the OS name) would use fewer keys, and keep replacing them. |
FYI, when persisting GOCACHE via |
This is an awesome resource, thank you!
I noticed you use
${{ hashFiles('**/go.sum') }}
as a cache key for the module cache. I am not sure that does what it is intended for, since thego.sum
file does not contain a hash of the module itself, and it might be missing from a module with no dependencies. IfhashFiles
includes the file names in the key, you could just use thego.mod
files instead, but even that would exclude modules that did not update.The text was updated successfully, but these errors were encountered: