Repository navigation
ateapi: prefer less-loaded workers via power of two choices - #1915
Conversation
|
Convention nit (AGENTS.md, "Commit Messages"): the commit message references |
435a4ef to
0d9382e
Compare
Thanks Aditya Shantanu (@aditya-shantanu) for the fast review. Resolved all comments. |
With multi-actor worker support enabled by default, selecting a single worker uniformly at random across all candidates with remaining capacity can stack actors onto busy workers while lighter workers exist, whereas strict global least-loaded selection over the asynchronous watch cache causes concurrent bursts to herd onto the same worker. Update Schedule to sample two distinct eligible candidates with room and pick the less-loaded one, comparing actor-slot utilization first and breaking ties on dominant compute-resource utilization and remaining actor slots.
0d9382e to
cce50d2
Compare
Address review feedback on agent-substrate#1915: - Compare max(actor-slot utilization, compute utilization) so a worker near its memory/CPU limit no longer wins just by hosting one fewer actor. Slot utilization and remaining slots remain as tie-breaks. - Return the wrapped parse error for malformed limits instead of ErrNoCapacity, so a bad template is not reported as no free workers. - Test the j >= i shift in pair sampling and the malformed-limits path.
Benjamin Elder (BenTheElder)
left a comment
There was a problem hiding this comment.
thanks!
Summary
With multi-actor worker support (#1836) enabled by default (
--max-actors=1000), selecting a single worker uniformly at random across all candidates with remaining capacity can stack actors onto busy workers while lighter workers exist, whereas strict global least-loaded selection over the asynchronous watch cache can cause concurrent bursts to herd onto the same worker.This change updates
Scheduler.Scheduleto use power of two choices: sample two distinct eligible candidates that satisfyHasRoomand pick the less-loaded one, comparing actor-slot utilization (Allocated.Actors / Capacity.Actors) first and breaking ties on dominant compute-resource utilization (CPU/memory).Testing
Added unit tests covering power-of-two-choices ordering, heterogeneous worker actor-capacity utilization, compute-resource utilization tie-breaking, fallback when an idle worker lacks resource room, and tie-breaking reachability in
cmd/ateapi/internal/scheduling/scheduling_test.go.Tests pass
Appropriate changes to documentation are included in the PR