[chore]: Bump go.uber.org/automaxprocs from 1.5.3 to 1.6.0 (#3376)
Bumps [go.uber.org/automaxprocs](https://github.com/uber-go/automaxprocs) from 1.5.3 to 1.6.0. - [Release notes](https://github.com/uber-go/automaxprocs/releases) - [Changelog](https://github.com/uber-go/automaxprocs/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/automaxprocs/compare/v1.5.3...v1.6.0) --- updated-dependencies: - dependency-name: go.uber.org/automaxprocs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
188d28f054
commit
e3019eada4
2
go.mod
2
go.mod
|
@ -72,7 +72,7 @@ require (
|
||||||
go.opentelemetry.io/otel/sdk v1.29.0
|
go.opentelemetry.io/otel/sdk v1.29.0
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.29.0
|
go.opentelemetry.io/otel/sdk/metric v1.29.0
|
||||||
go.opentelemetry.io/otel/trace v1.29.0
|
go.opentelemetry.io/otel/trace v1.29.0
|
||||||
go.uber.org/automaxprocs v1.5.3
|
go.uber.org/automaxprocs v1.6.0
|
||||||
golang.org/x/crypto v0.27.0
|
golang.org/x/crypto v0.27.0
|
||||||
golang.org/x/image v0.20.0
|
golang.org/x/image v0.20.0
|
||||||
golang.org/x/net v0.29.0
|
golang.org/x/net v0.29.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -652,8 +652,8 @@ go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt3
|
||||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||||
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||||
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
|
|
|
@ -25,15 +25,18 @@ package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
|
||||||
|
|
||||||
cg "go.uber.org/automaxprocs/internal/cgroups"
|
cg "go.uber.org/automaxprocs/internal/cgroups"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CPUQuotaToGOMAXPROCS converts the CPU quota applied to the calling process
|
// CPUQuotaToGOMAXPROCS converts the CPU quota applied to the calling process
|
||||||
// to a valid GOMAXPROCS value.
|
// to a valid GOMAXPROCS value. The quota is converted from float to int using round.
|
||||||
func CPUQuotaToGOMAXPROCS(minValue int) (int, CPUQuotaStatus, error) {
|
// If round == nil, DefaultRoundFunc is used.
|
||||||
cgroups, err := newQueryer()
|
func CPUQuotaToGOMAXPROCS(minValue int, round func(v float64) int) (int, CPUQuotaStatus, error) {
|
||||||
|
if round == nil {
|
||||||
|
round = DefaultRoundFunc
|
||||||
|
}
|
||||||
|
cgroups, err := _newQueryer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, CPUQuotaUndefined, err
|
return -1, CPUQuotaUndefined, err
|
||||||
}
|
}
|
||||||
|
@ -43,7 +46,7 @@ func CPUQuotaToGOMAXPROCS(minValue int) (int, CPUQuotaStatus, error) {
|
||||||
return -1, CPUQuotaUndefined, err
|
return -1, CPUQuotaUndefined, err
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProcs := int(math.Floor(quota))
|
maxProcs := round(quota)
|
||||||
if minValue > 0 && maxProcs < minValue {
|
if minValue > 0 && maxProcs < minValue {
|
||||||
return minValue, CPUQuotaMinUsed, nil
|
return minValue, CPUQuotaMinUsed, nil
|
||||||
}
|
}
|
||||||
|
@ -57,6 +60,7 @@ type queryer interface {
|
||||||
var (
|
var (
|
||||||
_newCgroups2 = cg.NewCGroups2ForCurrentProcess
|
_newCgroups2 = cg.NewCGroups2ForCurrentProcess
|
||||||
_newCgroups = cg.NewCGroupsForCurrentProcess
|
_newCgroups = cg.NewCGroupsForCurrentProcess
|
||||||
|
_newQueryer = newQueryer
|
||||||
)
|
)
|
||||||
|
|
||||||
func newQueryer() (queryer, error) {
|
func newQueryer() (queryer, error) {
|
||||||
|
|
|
@ -26,6 +26,6 @@ package runtime
|
||||||
// CPUQuotaToGOMAXPROCS converts the CPU quota applied to the calling process
|
// CPUQuotaToGOMAXPROCS converts the CPU quota applied to the calling process
|
||||||
// to a valid GOMAXPROCS value. This is Linux-specific and not supported in the
|
// to a valid GOMAXPROCS value. This is Linux-specific and not supported in the
|
||||||
// current OS.
|
// current OS.
|
||||||
func CPUQuotaToGOMAXPROCS(_ int) (int, CPUQuotaStatus, error) {
|
func CPUQuotaToGOMAXPROCS(_ int, _ func(v float64) int) (int, CPUQuotaStatus, error) {
|
||||||
return -1, CPUQuotaUndefined, nil
|
return -1, CPUQuotaUndefined, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
// CPUQuotaStatus presents the status of how CPU quota is used
|
// CPUQuotaStatus presents the status of how CPU quota is used
|
||||||
type CPUQuotaStatus int
|
type CPUQuotaStatus int
|
||||||
|
|
||||||
|
@ -31,3 +33,8 @@ const (
|
||||||
// CPUQuotaMinUsed is returned when CPU quota is smaller than the min value
|
// CPUQuotaMinUsed is returned when CPU quota is smaller than the min value
|
||||||
CPUQuotaMinUsed
|
CPUQuotaMinUsed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DefaultRoundFunc is the default function to convert CPU quota from float to int. It rounds the value down (floor).
|
||||||
|
func DefaultRoundFunc(v float64) int {
|
||||||
|
return int(math.Floor(v))
|
||||||
|
}
|
||||||
|
|
|
@ -37,9 +37,10 @@ func currentMaxProcs() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
printf func(string, ...interface{})
|
printf func(string, ...interface{})
|
||||||
procs func(int) (int, iruntime.CPUQuotaStatus, error)
|
procs func(int, func(v float64) int) (int, iruntime.CPUQuotaStatus, error)
|
||||||
minGOMAXPROCS int
|
minGOMAXPROCS int
|
||||||
|
roundQuotaFunc func(v float64) int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) log(fmt string, args ...interface{}) {
|
func (c *config) log(fmt string, args ...interface{}) {
|
||||||
|
@ -71,6 +72,13 @@ func Min(n int) Option {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RoundQuotaFunc sets the function that will be used to covert the CPU quota from float to int.
|
||||||
|
func RoundQuotaFunc(rf func(v float64) int) Option {
|
||||||
|
return optionFunc(func(cfg *config) {
|
||||||
|
cfg.roundQuotaFunc = rf
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
type optionFunc func(*config)
|
type optionFunc func(*config)
|
||||||
|
|
||||||
func (of optionFunc) apply(cfg *config) { of(cfg) }
|
func (of optionFunc) apply(cfg *config) { of(cfg) }
|
||||||
|
@ -82,8 +90,9 @@ func (of optionFunc) apply(cfg *config) { of(cfg) }
|
||||||
// configured CPU quota.
|
// configured CPU quota.
|
||||||
func Set(opts ...Option) (func(), error) {
|
func Set(opts ...Option) (func(), error) {
|
||||||
cfg := &config{
|
cfg := &config{
|
||||||
procs: iruntime.CPUQuotaToGOMAXPROCS,
|
procs: iruntime.CPUQuotaToGOMAXPROCS,
|
||||||
minGOMAXPROCS: 1,
|
roundQuotaFunc: iruntime.DefaultRoundFunc,
|
||||||
|
minGOMAXPROCS: 1,
|
||||||
}
|
}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o.apply(cfg)
|
o.apply(cfg)
|
||||||
|
@ -102,7 +111,7 @@ func Set(opts ...Option) (func(), error) {
|
||||||
return undoNoop, nil
|
return undoNoop, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProcs, status, err := cfg.procs(cfg.minGOMAXPROCS)
|
maxProcs, status, err := cfg.procs(cfg.minGOMAXPROCS, cfg.roundQuotaFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return undoNoop, err
|
return undoNoop, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,4 +21,4 @@
|
||||||
package maxprocs
|
package maxprocs
|
||||||
|
|
||||||
// Version is the current package version.
|
// Version is the current package version.
|
||||||
const Version = "1.5.2"
|
const Version = "1.6.0"
|
||||||
|
|
|
@ -1046,8 +1046,8 @@ go.opentelemetry.io/proto/otlp/collector/trace/v1
|
||||||
go.opentelemetry.io/proto/otlp/common/v1
|
go.opentelemetry.io/proto/otlp/common/v1
|
||||||
go.opentelemetry.io/proto/otlp/resource/v1
|
go.opentelemetry.io/proto/otlp/resource/v1
|
||||||
go.opentelemetry.io/proto/otlp/trace/v1
|
go.opentelemetry.io/proto/otlp/trace/v1
|
||||||
# go.uber.org/automaxprocs v1.5.3
|
# go.uber.org/automaxprocs v1.6.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.20
|
||||||
go.uber.org/automaxprocs/internal/cgroups
|
go.uber.org/automaxprocs/internal/cgroups
|
||||||
go.uber.org/automaxprocs/internal/runtime
|
go.uber.org/automaxprocs/internal/runtime
|
||||||
go.uber.org/automaxprocs/maxprocs
|
go.uber.org/automaxprocs/maxprocs
|
||||||
|
|
Loading…
Reference in New Issue