Skip to content
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

proposal: cmd/go: allow disabling build cache trimming #69565

Open
rittneje opened this issue Sep 20, 2024 · 5 comments
Open

proposal: cmd/go: allow disabling build cache trimming #69565

rittneje opened this issue Sep 20, 2024 · 5 comments
Labels
Milestone

Comments

@rittneje
Copy link

Proposal Details

We have our own docker image containing our Go toolchain. As an optimization, we also pre-compile the standard library (go build std) so that it is in the gocache.

Evidently, the various Go tools will trim the cache upon exit. In particular, they will delete any files in the cache that have not been modified in the last five days. While this may be reasonable for a cache on someone's host machine, it does not make sense for a short-lived container using a cache from its image, since the mtimes will all reflect when the image was built. At best, it trimming the cache is pointless because the container will be destroyed shortly, and at worst is actively counterproductive as those cached files may be used by subsequent commands.

Please add an environment variable to disable trimming the gocache upon command exit. The specific name is immaterial, but something like GOCACHE_AUTO_TRIM=0 would be fine.

@gopherbot gopherbot added this to the Proposal milestone Sep 20, 2024
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@ianlancetaylor
Copy link
Member

CC @matloob

@matloob
Copy link
Contributor

matloob commented Sep 24, 2024

I don't know if this justifies its own environment variable (that would show up in go env, etc.) but maybe we can make it an undocumented # godebug setting?

@rittneje
Copy link
Author

@matloob If you mean something we can set via the GODEBUG environment variable, that would also be acceptable. We just need something we can easily configure globally in the base image.

@matloob
Copy link
Contributor

matloob commented Sep 25, 2024

Yes. That is what I mean.

@seankhliao seankhliao changed the title proposal: cmd/go: allow disabling gocache trimming proposal: cmd/go: allow disabling build cache trimming Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

5 participants