Set default max image scaler procs to num_cpu / 2
What it says in the title. The recommendation is to use num_cores / 2
as a safe default. We also pin to a minimum of 2 concurrent processes so as to allow for a minimum of image scaling availability with less than 4 cores.
Context: gitlab-org/charts/gitlab!1595 (comment 433518692)
This MR also addresses a problem with our scaler tests: since we weren't sending a cancel
signal to the request context, the goroutine that decrements the atomic counter was blocking on that channel forever. I noticed since some tests started to fail on CI where num_cores / 2 = 1
, and after the first test ran and the counter didn't go down, the next test failed with 1 / 1
procs are running. I addressed this by moving the process counter into the resizer type itself, so that we can easily reset state between tests.