Skip to content

Abstract out concurrency limiter's queues

Extracted from !6353 (closed)

This MR adds two changes:

  • Replace the concurrency limiter's ticker generator with context timeout. The ticker generator returns a new ticker when called to handle the timeout event. Replace it with a context timeout is more elegant. A prerequisite is to implement a test helper that allows the test trigger the timeout event manually.
  • Abstract out concurrency limiter's queues. The concurrency limiter controls the concurrency and queueing mechanism using two buffered channels. Naturally, we can consider them as two weighted semaphores. This commit extracts the core operations of those two semaphores to a staticSemaphore struct. This extraction also standardizes the interface so that the forward commits can swap in another semaphore implementation (demonstrated in !6353 (closed)).

Manual tests

I performed some manual tests on the local to verify the refactoring still works as expected.

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
Edited by Quang-Minh Nguyen

Merge request reports