Skip to content

limiter: Add adaptive limit to the concurrency limiter (second attempt)

For #5523 (closed)

This MR is the re-implementation of !6183 (merged), which was reverted due to a memory-leak incident.

Similar to the prior MR, this MR adds support to the adaptive limit to the concurrency limiter. This addition doesn't enable the adaptive calculator, which is responsible for adjusting the limit up and down accordingly. Hence, there shouldn't be any change in functionality and how the current limiters work. They still use the static values.

To avoid another accident, this MR introduces some significant enhancements:

  • The new ResizableSemaphore (implemented in !6366 (merged))
  • The limiter generalizes the current semaphore implementation, which uses two buffered channels. The MR introduces a feature flag for swapping in the new resizable semaphore gradually.
  • Test coverage for both static and resizable semaphores to co-exist at the same time.

After this MR is merged, there shouldn't be any change. The limiter uses an abstract static semaphore based on buffered channels (!6355 (merged)). After the flag is on, the new resizable semaphore kicks in gradually.

Manual tests

Two scenarios work well before and after gitaly_use_resizable_semaphore_in_concurrency_limiter flag is enabled.

Concurrency limit Pack-object limit
Under the limit
Wait in queue
Wait when max_queue_size = 0
Exceed queue size
Timeout waiting in queue
Timeout when max_queue_size = 0
Transition before and after enabling FF
Edited by Quang-Minh Nguyen

Merge request reports