executor/resource: stub out NewSysSampler on Windows#4040
Conversation
6e6c2d2 to
42cfdae
Compare
| 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.
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
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.
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.