Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0be3333730 | ||
|
|
198f92a5f8 | ||
|
|
5c795429b8 |
@@ -40,7 +40,6 @@ 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 }{
|
||||||
@@ -197,7 +196,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{"", " ", "0.5", "half", "-1", "4 images"} {
|
for _, value := range []string{"", " ", "1.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,9 +187,7 @@ 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 {
|
||||||
const cpusPerImage = 2
|
return max(runtime.GOMAXPROCS(0)/2, 1)
|
||||||
|
|
||||||
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,7 +139,6 @@ 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