-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
allow controlling detected platforms cache timeout #4949
Conversation
@@ -245,10 +245,14 @@ func (w *Worker) Labels() map[string]string { | |||
|
|||
func (w *Worker) Platforms(noCache bool) []ocispecs.Platform { | |||
if noCache { | |||
matchers := make([]platforms.MatchComparer, len(w.WorkerOpt.Platforms)) | |||
for i, p := range w.WorkerOpt.Platforms { | |||
matchers[i] = platforms.Only(p) |
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.
Although the effect of this isn't that significant compared to qemu detection logic, calling platforms.Only
isn't completely free either as it internally allocates memory for the variant vector arrays.
55edeed
to
dcf5e03
Compare
This is a fix for docker/buildx#2474, correct? |
|
||
"github.com/containerd/containerd/platforms" | ||
"github.com/moby/buildkit/util/bklog" | ||
ocispecs "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
var mu sync.Mutex | ||
var arr []ocispecs.Platform | ||
var CacheMaxAge = 20 * time.Second |
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.
Out of curiosity. How often does this change during the lifetime of a buildkit process? I guess it would only change on an install of new binfmt handlers right?
Potentially, could we invalidate the cache based on the contents of /proc/sys/fs/binfmt_misc/
? Just a thought, curious if you considered this option.
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.
How often does this change during the lifetime of a buildkit process? I guess it would only change on an install of new binfmt handlers right?
Yeah, it depends on what the user is doing outside of buildkit.
Potentially, could we invalidate the cache based on the contents of /proc/sys/fs/binfmt_misc/?
binfmt_misc is usually not mounted in the environment where buildkit runs
Not directly. |
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.
Can you add this new config to https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md?
type SystemConfig struct { | ||
// PlatformCacheMaxAge controls how often supported platforms | ||
// are refreshed by rescanning the system. | ||
PlatformsCacheMaxAge *Duration `toml:"platformsCacheMaxAge"` |
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.
Is it possible to always use cache by setting platformsCacheMaxAge = -1
with this custom type?
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.
Yes, I tested this
Because detecting emulator changes can be relatively expensive, avoid doing it very frequently. A new config parameter allows controlling if users prefer more or less frequent updates or want to disable detecting changes completely and only rely on emultor configuration at boot time. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
dcf5e03
to
9c29e21
Compare
Because detecting emulator changes can be relatively expensive, avoid doing it very frequently. A new config parameter allows controlling if users prefer more or less frequent updates or want to disable detecting changes completely and only rely on emultor configuration at boot time.