-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
executor/resource: stub out NewSysSampler on Windows #4040
Conversation
6e6c2d2
to
42cfdae
Compare
executor/resources/sys_nolinux.go
Outdated
func newSysSampler() (*Sampler[*types.SysSample], error) { | ||
return NewSampler(2*time.Second, 20, func(_ time.Time) (*types.SysSample, error) { return nil, nil }), nil | ||
} |
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.
TBH; wasn't sure if return nil, nil
would work, but looks like it's happy
Also was hoping to make this function return nil
, but not sure if that would work, as it's called unconditionally;
buildkit/solver/llbsolver/solver.go
Lines 419 to 420 in d9a6afd
usage := s.sysSampler.Record() | |
defer usage.Close(false) |
I was initially thinking along the lines of
var usage some.Type
if s.sysSampler != nil {
usage := s.sysSampler.Record()
defer usage.Close(false)
}
But honestly, generics are not yet "my thing", and I got confused what to use for some.Type
(.Record()
has a func (s *Sampler[T]) Record() *Sub[T]
signature)
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 type should just be *Sub[*types.SysSample]
.
FWIW; also testing these changes in moby/moby#46035 (well, currently from a locally patched "vendor", but didn't want to restart it). So it may be worth keeping an eye on that one to see if all works as expected. |
Commit 509cfa3 introduced the SysSampler, which measures resource consumption. However, for this it depends on prometheus' procfs. That package does not have build-tags but is a Linux-only implementation, which (by default) attempts to access `/proc`; https://github.com/prometheus/procfs/blob/v0.9.0/fs.go#L26-L33 https://github.com/prometheus/procfs/blob/v0.9.0/internal/fs/fs.go#L23-L24 This patch splits the implementation of "resource" into platform-specific files, and stubs out the NewSysSampler() on non-Linux platforms. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
ac50f4f
to
ce332e1
Compare
Yes I was considering to use |
Commit 509cfa3 (#3860) introduced the SysSampler, which measures resource consumption. However, for this it depends on prometheus' procfs. That package does not have build-tags but is a Linux-only implementation, which (by default) attempts to access
/proc
; https://github.com/prometheus/procfs/blob/v0.9.0/fs.go#L26-L33 https://github.com/prometheus/procfs/blob/v0.9.0/internal/fs/fs.go#L23-L24This patch splits the implementation of "resource" into platform-specific files, and stubs out the NewSysSampler() on non-Linux platforms.