Restrict OptimizeRepository's full repack to fewer threads
During a test of the Gitaly background maintenance worker, we observed high resource usage and a dramatic drop in IO while request latency increased: gitlab-com/gl-infra/production#3208 (comment 468729372)
One possible reason this may have occurred is due to a large repositories being fully repacked and hogging all cores on the server. One way to mitigate this is to restrict the pack-files process to using fewer threads. See a similar strategy used in Omnibus: omnibus-gitlab!417 (merged)
This will increase the time to optimize large repositories, but that is okay since this is a background process that runs for long periods of time.
Edited by Paul Okstad (ex-GitLab)