You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Task admission: a waiter with a smaller limit holds every waiter behind it until the pool is empty #386
Imp.Tasks.Admission keeps one FIFO queue of waiters for all pools and limits. grant_waiters/1 looks only at the head: if the head waiter cannot be granted (its limit is smaller than the pool's active count), it is put back and nothing behind it is granted, even waiters whose own limit has room (lib/imp/tasks.ex, grant_waiters/1, :queue.in_r).
So a waiter that came from Imp.context([async_max_workers: 1], ...) while the machine pool had other work blocks every default-limit (8) waiter queued after it until the pool's active count reaches 0. A new caller that arrives while active < limit is granted at once without queueing (handle_call({:reserve, ...})), so it can also overtake waiters already queued.
Measured with a scratch test: 7 of 8 places freed at 300 ms, one held until 2 s, a limit-1 waiter queued first: a limit-8 waiter behind it got its place at about 2,000 ms instead of about 300 ms.
The moduledoc says a task "waits for a place when the pool is full"; here it waits while 7 places are free.
Possible fixes: grant any queued waiter whose own limit has room (skip, don't stop at, a head that can't be granted), or keep one queue per (pool, limit); and decide whether a new caller should queue behind existing waiters. Found while looking at #379; #382 widens that test's wait meanwhile.
Activity