limiter: Add adaptive limit to the concurrency limiter
A part of #5376 (closed)
This MR adds the adaptive limit to limiter.ConcurrencyLimiter
. It
changes the signature of the initializer to receive an AdaptiveLimit
object and converts the queues in the limiter to dynamic pools. At this
point, as the calculator has not been integrated (yet), the input limit
never changes. It always returns a persistent limit, which is a perfect
replacement for the integer static limit. After this MR is merged, we don't expect any changes in how pack-objects limiting work.
In the future, when the calculator kicks in, the dynamic pools in the concurrency limiter scales up and down accordingly when the current limit is changed by the calculator.
Internally, limiter.ConcurrencyLimiter
implements two buffered channels to synchronize request concurrency and queueing. As buffered channels are unable to be adjusted after initialization, it's not feasible to add the adaptive capacity. This MR replaces them with a dynamic pool with size-adjusting capacity.