codingjoe / codingjoe/threadmill
Batch acquire: take up to N tasks per call across non-empty queues
- Lingua principale
- Python
- Stelle
- 12
- Fork
- 1
- Merge medio
- 1g 1h
- PR unite (30g)
- 10
Descrizione
Split out of #48 during the fair multi-queue scheduling change (`codingjoe-fair-multi-queue-scheduling`).
`defer: Batch acquire (fetch up to N tasks per call across non-empty queues). Needs executor fetch-and-dispatch; the lease would tick while tasks wait in-process. [threadmill/backends/redis.py]`
## Why
`acquire()` pops a single task per script call, so a process with `--threads 4` performs four Redis round trips to fill its threads. A batch acquire that spreads up to N tasks across the non-empty queues would cut round trips and drain several queues in parallel.
## What makes it non-trivial
- `WorkerProcess` runs one `WorkerThread` per thread, each calling `acquire()` itself. A batch would need a fetch-and-dispatch step, since a single thread cannot execute N tasks at once.
- `acquire.lua` moves the task into the running set with `deadline = now + lease_ttl`. Tasks prefetched into an in-process queue would burn lease budget while waiting, so the reaper could fail them, or the lease clock has to start at execution instead.
- Graceful shutdown must return prefetched, unstarted tasks to the ready set instead of leaving them to be reaped as FAILED.
Pop and move must stay inside one script call.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Leggi prima threadmill/backends/redis.py e acquire.lua, quindi segui WorkerProcess e WorkerThread per comprendere l’attuale flusso di acquire per thread. Definisci come fetch-and-dispatch gestisce il timing del lease, l’arresto ordinato e i task precaricati, mantenendo pop e move in un’unica chiamata allo script. Il lavoro è completo quando è possibile acquisire fino a N task tra queue non vuote senza lasciare lavoro bloccato o farlo fallire prematuramente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, redis
- Ambito
- backend, distributed-systems
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100