The default is the number of CPUs Go uses, so a container with no CPU limit on a host with many CPUs processes one image per CPU at once. These tests fail until the default in the config and in imageprocessor.New is held to 4 (#242). Model: opus-5-5
This commit is contained in:
@@ -132,6 +132,27 @@ func TestNewDefaultsMaxConcurrentProcessingToCPUs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewDefaultMaxConcurrentProcessingIsAtMostFour checks that New, given
|
||||
// no MaxConcurrentProcessing, makes one slot per CPU Go uses, but never more
|
||||
// than 4.
|
||||
func TestNewDefaultMaxConcurrentProcessingIsAtMostFour(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
want := min(runtime.GOMAXPROCS(0), 4)
|
||||
|
||||
for _, limit := range []int{0, -1} {
|
||||
proc := New(Params{MaxConcurrentProcessing: limit})
|
||||
got := cap(proc.processingSemaphore)
|
||||
t.Logf("MaxConcurrentProcessing %d, GOMAXPROCS %d: %d slots",
|
||||
limit, runtime.GOMAXPROCS(0), got)
|
||||
|
||||
if got != want {
|
||||
t.Errorf("MaxConcurrentProcessing %d: %d slots, want %d",
|
||||
limit, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestProcessNeverExceedsMaxConcurrentProcessing starts more Process calls
|
||||
// than MaxConcurrentProcessing allows and holds the first ones inside
|
||||
// Process until the test lets them go. No more than the limit may be
|
||||
|
||||
Reference in New Issue
Block a user