Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6602d5bf8 | ||
|
|
d0377ae3da | ||
|
|
fc5ffc91f1 |
@@ -40,6 +40,7 @@ func TestOmittedConcurrencyLimitsUseDefaults(t *testing.T) {
|
|||||||
//nolint:paralleltest // it sets GOMAXPROCS, which other tests read
|
//nolint:paralleltest // it sets GOMAXPROCS, which other tests read
|
||||||
func TestOmittedMaxConcurrentProcessingIsHalfTheCPUsAndAtLeastOne(t *testing.T) {
|
func TestOmittedMaxConcurrentProcessingIsHalfTheCPUsAndAtLeastOne(t *testing.T) {
|
||||||
cpusBefore := runtime.GOMAXPROCS(0)
|
cpusBefore := runtime.GOMAXPROCS(0)
|
||||||
|
|
||||||
t.Cleanup(func() { runtime.GOMAXPROCS(cpusBefore) })
|
t.Cleanup(func() { runtime.GOMAXPROCS(cpusBefore) })
|
||||||
|
|
||||||
for _, tc := range []struct{ cpus, want int }{
|
for _, tc := range []struct{ cpus, want int }{
|
||||||
@@ -196,7 +197,7 @@ func TestConcurrencyLimitsFromEnvironment(t *testing.T) {
|
|||||||
// least 1, an empty one included, aborts startup naming the variable and
|
// least 1, an empty one included, aborts startup naming the variable and
|
||||||
// the key instead of taking the default.
|
// the key instead of taking the default.
|
||||||
func TestInvalidMaxConcurrentProcessingFromEnvironmentAbortsStartup(t *testing.T) {
|
func TestInvalidMaxConcurrentProcessingFromEnvironmentAbortsStartup(t *testing.T) {
|
||||||
for _, value := range []string{"", " ", "1.5", "half", "-1", "4 images"} {
|
for _, value := range []string{"", " ", "0.5", "half", "-1", "4 images"} {
|
||||||
t.Run(fmt.Sprintf("value %q", value), func(t *testing.T) {
|
t.Run(fmt.Sprintf("value %q", value), func(t *testing.T) {
|
||||||
t.Setenv(testMaxConcurrentProcessingVar, value)
|
t.Setenv(testMaxConcurrentProcessingVar, value)
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,9 @@ type Params struct {
|
|||||||
// when none is set: half the CPUs Go uses (runtime.GOMAXPROCS(0), which
|
// when none is set: half the CPUs Go uses (runtime.GOMAXPROCS(0), which
|
||||||
// follows a container's CPU limit), rounded down, and at least 1.
|
// follows a container's CPU limit), rounded down, and at least 1.
|
||||||
func DefaultMaxConcurrentProcessing() int {
|
func DefaultMaxConcurrentProcessing() int {
|
||||||
return max(runtime.GOMAXPROCS(0)/2, 1)
|
const cpusPerImage = 2
|
||||||
|
|
||||||
|
return max(runtime.GOMAXPROCS(0)/cpusPerImage, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new image processor with the given parameters.
|
// New creates a new image processor with the given parameters.
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ func TestNewDefaultsMaxConcurrentProcessingToHalfTheCPUs(t *testing.T) {
|
|||||||
//nolint:paralleltest // it sets GOMAXPROCS, which other tests read
|
//nolint:paralleltest // it sets GOMAXPROCS, which other tests read
|
||||||
func TestNewDefaultIsHalfTheCPUsAndAtLeastOne(t *testing.T) {
|
func TestNewDefaultIsHalfTheCPUsAndAtLeastOne(t *testing.T) {
|
||||||
cpusBefore := runtime.GOMAXPROCS(0)
|
cpusBefore := runtime.GOMAXPROCS(0)
|
||||||
|
|
||||||
t.Cleanup(func() { runtime.GOMAXPROCS(cpusBefore) })
|
t.Cleanup(func() { runtime.GOMAXPROCS(cpusBefore) })
|
||||||
|
|
||||||
for _, tc := range []struct{ cpus, want int }{
|
for _, tc := range []struct{ cpus, want int }{
|
||||||
|
|||||||
Reference in New Issue
Block a user