Repository navigation
Labels
area/lifecycleRelated to lifecycle of an actor.area/schedulingkind/cleanupSmall fixes that are not bugs, for example a typo in a code comment
Milestone
Description
Problem
Resuming a paused actor (an asynchronous suspend whose local checkpoint is still on its node) is the most latency-sensitive resume path in Substrate. Because the actor's status.assigned_node is set, schedulingConstraints sets Constraints.RequiredNodes to that single node so the actor resumes from its local checkpoint.
Today, workercache.Cache (cmd/ateapi/internal/workercache/workercache.go) only stores a flat map[string]*ateapi.Worker keyed by worker name:
-
Full-cluster copy on every pinned resume: Even when
Constraints.RequiredNodesnames a single node,Scheduler.Schedulecallss.source.Workers(), which takes the cache read lock, iterates every worker in the cluster, and allocates a full[]*ateapi.Workerslice. -
$O(\text{cluster})$ filtering for a single node:Schedulethen loops over all$N$ workers in the cluster only formatchesStaticto discard every worker whoseNodeNameis not inRequiredNodes. On a 1,000-node cluster with 4 workers per node, a paused resume copies and checks 4,000 workers to inspect the 4 workers onassigned_node. -
Double scan when the pinned node is full: If the pinned node has no room,
assignWorkerAttemptscans all$N$ workers for the pinned node, fails withErrNoCapacity, and thendetachFromFullNodescans all$N$ workers again across the cluster.
Proposal
Index workers by NodeName inside workercache.Cache so node-pinned scheduling only reads the workers on the requested node(s):
- Maintain a per-node index in
workercache: A worker'sNodeNameis fixed for its lifetime, andCacheonly mutatesc.workersin three places (relist,applyEvent, andForget). Keep abyNodemap alongsidec.workersin those three paths. - Query only the target node(s) when
RequiredNodesis set: WhenConstraints.RequiredNodesis non-empty,Schedulefetches only the workers on those nodes fromworkercacheinstead of callingWorkers(). WhenRequiredNodesis empty (unpinned resume or cold boot),Schedulereads the full fleet as before.
This reduces worker lookup and evaluation on every paused-actor resume from
Metadata
Metadata
Assignees
Labels
area/lifecycleRelated to lifecycle of an actor.area/schedulingkind/cleanupSmall fixes that are not bugs, for example a typo in a code comment
Activity