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
Prefer workers with cached actor images during scheduling #276
Atelet maintains a node-local image cache, but the scheduler does not know which images are cached on each node. As a result, an actor may be assigned to a cold node and pull its images again, even when another eligible node already has them cached.
Image preparation happens synchronously during ResumeActor, so unnecessary pulls increase actor startup latency and registry traffic.
Proposal
Let atelet report its cached image digests to the control plane.
Store cache information by node.
After applying existing constraints, prefer available workers whose node has all required actor images cached.
Fall back to the current random selection when no cache hit is available.
Local snapshot availability remains a hard constraint. Image cache affinity is applied only among nodes that can restore the selected snapshot.
A general scoring framework is not required: use cache-hit preference with fallback.
Expected Outcome
Reduce unnecessary image pulls and improve Actor Resume latency and consistency.
Following up on Julian Gutierrez Oschmann (@juli4n)'s comment on PR #298 — I agree we should agree on a unified approach for node-locality before landing more one-off scheduling features.
Where we are today
Only one node-locality mechanism is merged: when an actor is paused with a local snapshot, NodeVmsWithLocalSnapshots on the Actor record is a hard constraint during ResumeActor — workers must be on one of those nodes.
#276 / PR #298 proposes a second path (not merged yet): atelet periodically reports OCI image digests, control plane stores them per node with a TTL, and the scheduler prefers workers whose node already has the required images, falling back to random selection.
The concern isn't that we already run two models in production — it's that merging #298 as a standalone RPC and store key sets a pattern that #228 (rootfs overlay), #135 (hot snapshot cache), and future volume locality will likely copy unless we align now.
Proposed direction
Split two concerns:
Actor-bound, durable, hard constraints — e.g. pause local snapshot nodes. Stays on the Actor record.
Node-bound, TTL-backed, soft preferences — e.g. warm images, extracted rootfs, resident snapshots. One shared node inventory reported periodically by atelet and stored per node. Stale or wrong data should only hurt latency, not correctness.
Keep the Prefer workers with cached actor images during scheduling #276 scheduling model: fixed layers (hard filter → ordered soft preferences → random fallback), not a general scoring framework.
Soft preference order (when we add them): hot snapshot on node first, then rootfs overlay (#228), then image tar cache (#276). Pause local snapshots remain hard-only via the Actor record — don't move them into node inventory.
Rough plan
Phase 0 (this issue): agree on hard vs soft split, node inventory as the long-term envelope, and preference ordering. Don't ossify ReportNodeImageCache as the permanent API.
Phase 1: implement #276 on NodeInventory directly (rebase PR #298 onto that, rather than merge then rename).
Phase 2: add rootfs overlay digests from #228.
Phase 3: add resident snapshot prefixes for Suspend hot-restore (#135 light).
Phase 4 (later): secondary indexes / #135 ListOptions only if query patterns prove we need them.
Happy to help turn Phase 0 into a short design note here if that's useful.
I ran an RL trainer shape on Substrate: 32 images with 16 rollouts each per step, 60 steps, 1,920 distinct images, 783 nodes. Every rollout of an image landed on a different node, and every node pulled the image.
Measured
Cold pulls per actor
0.96
Pulls for 1,920 images
29,301 (about 32 per step would do)
Image unpack per actor
28 s, 97% of the start time
Step time
~2 min, against 15 to 30 s when the images are already on the nodes
One more thing: a restore from a golden snapshot onto a node without the image costs the same as booting the image, because the golden download and the gVisor restore together are about 0.3 s. So the preference you describe is also what makes golden snapshots pay off.
Another consumer, and two asks for the unified node-locality approach this thread wants.
In ai-on-gke/sandboxenv-rl we are planning a pre-flight that fills node image caches before an RL job (ai-on-gke/sandboxenv-rl#205): with placement image-blind, the first boot of each image pays the unpack on whatever node it lands on, and #3481's numbers (unpack 1 ms with the layers on the node, 9–50 s without, ~97 % of a cold first command) are what the job sees. The workaround available on main is client-side: WorkerPools as placement domains, each with its own label, and Actor.worker_selector per actor to keep an image's actors inside the domain that holds it. A scheduler preference like PR #298 would retire that.
Until it lands, a client needs two things the API does not give today:
A way to place on a node without one WorkerPool per node: either mirror a configurable set of node labels (kubernetes.io/hostname, zone, node pool) into Worker.labels at registration, which worker_selector can then name, or a per-actor node affinity composed into the RequiredNodes the scheduler already has for local snapshots.
Visibility of which images a node holds. Prefer workers with cached actor images during scheduling #298 already has atelet report cached digests to ate-api; exposing that report (a gauge with the digest per node, or a field on Worker.status) lets a client verify a warm node and choose where to send an image's actors, and it is also how an operator would see a pre-warm took.
Happy to write either up in more detail if it helps the unified design.
Picking up the Phase 0 design note han2ni3bal-pixel offered above. I'd like to help write it, and I think it should also cover threads opened since June that touch the same code: #3528 (suspended actors are invisible to load), #589 / #3482 (what happens when the pinned node can't take the resume), and #3783 (placement cost grows with the fleet). A concept to react to before anyone writes code:
1. Keep the layered model and name the layers
I agree with fixed layers over a scoring framework. Proposed order per placement:
Layer
Signal
Kind
Source
0
sandbox class, runtime, selectors, room
hard
today's Applies / HasRoom
1
node holding the actor's local snapshot
hard while the snapshot is local only; preference once the durable copy is COMPLETED
Inside each layer, keep power-of-two choices among the matching workers, so a preference narrows the pool without sending every resume to the one warm node.
Layer 1 is the substantive change. Today the pin is released only by detach (the timer, or a full node at resume time). Two cases slip through: a node whose worker is draining (Aditya Shantanu (@aditya-shantanu)'s test in #589 sees ~10 s of ResourceExhausted while another worker sits idle) and workers without limits, which never look full (#3479). Once the durable copy is COMPLETED, the node can drop to a preference: a busy or draining node then costs a download, and the resume no longer fails. #2970's in-order attempts on the node fit inside this layer.
2. Count suspended-but-bound actors as load (#3528)
Use them as the load signal inside each layer. They never count against capacity, so they can't block placement. Benjamin Elder (@BenTheElder), if the LRU mitigation for 1.1 lands first, this layer reads the same count.
3. Zone as the second topology level
Workers carry node_name and labels but no zone. Mirroring a small configured set of node labels (topology.kubernetes.io/zone, node pool) into Worker.labels at registration, as Tomer Glottmann (@tomergee) suggested above, gives layer 5 and lets operators define placement domains without one WorkerPool per node.
Index the worker cache by node (#3002) and by zone, so layers 1–5 look candidates up instead of scanning the fleet, and run the cheap checks before parsing cpu_features (#3924).
For the scans that remain (the detach pre-check #3810, the strict runtime pass #3779, a saturated fleet), cache “no room” results per constraint shape and scope (fleet, zone, node). Each cached “no” carries the generation of its scope. The worker cache bumps a generation only on events that can create room: a new worker, a worker turning ACTIVE, allocated going down, capacity going up, a new registered_epoch, or changed labels. Binds and deletes only remove room, so they leave cached results valid, which keeps the hit rate high under burst load. The bind’s admit check under the row lock stays as it is, so a cached answer can never cause a wrong bind. I’d ship it behind a flag in shadow mode first, counting disagreements with a real scan before enabling it.
Example: Anthropic's KubeCon NA scheduler talk reported sub-3 ms per placement at 65K nodes largely from that ordering.
5. Errors name the layer that failed
When every layer is empty, ResourceExhausted says whether the pinned node was full or draining or the fleet was full, building on #398 / #401.
Activity
han2ni3bal-pixel commentedon Jun 26, 2026
Following up on Julian Gutierrez Oschmann (@juli4n)'s comment on PR #298 — I agree we should agree on a unified approach for node-locality before landing more one-off scheduling features.
Where we are today
Only one node-locality mechanism is merged: when an actor is paused with a local snapshot, NodeVmsWithLocalSnapshots on the Actor record is a hard constraint during ResumeActor — workers must be on one of those nodes.
#276 / PR #298 proposes a second path (not merged yet): atelet periodically reports OCI image digests, control plane stores them per node with a TTL, and the scheduler prefers workers whose node already has the required images, falling back to random selection.
The concern isn't that we already run two models in production — it's that merging #298 as a standalone RPC and store key sets a pattern that #228 (rootfs overlay), #135 (hot snapshot cache), and future volume locality will likely copy unless we align now.
Proposed direction
Split two concerns:
Keep the Prefer workers with cached actor images during scheduling #276 scheduling model: fixed layers (hard filter → ordered soft preferences → random fallback), not a general scoring framework.
Soft preference order (when we add them): hot snapshot on node first, then rootfs overlay (#228), then image tar cache (#276). Pause local snapshots remain hard-only via the Actor record — don't move them into node inventory.
Rough plan
Phase 0 (this issue): agree on hard vs soft split, node inventory as the long-term envelope, and preference ordering. Don't ossify ReportNodeImageCache as the permanent API.
Phase 1: implement #276 on NodeInventory directly (rebase PR #298 onto that, rather than merge then rename).
Phase 2: add rootfs overlay digests from #228.
Phase 3: add resident snapshot prefixes for Suspend hot-restore (#135 light).
Phase 4 (later): secondary indexes / #135 ListOptions only if query patterns prove we need them.
Happy to help turn Phase 0 into a short design note here if that's useful.
vicentefb commentedon Oct 30, 2026
adding a measurement that argues for this.
I ran an RL trainer shape on Substrate: 32 images with 16 rollouts each per step, 60 steps, 1,920 distinct images, 783 nodes. Every rollout of an image landed on a different node, and every node pulled the image.
One more thing: a restore from a golden snapshot onto a node without the image costs the same as booting the image, because the golden download and the gVisor restore together are about 0.3 s. So the preference you describe is also what makes golden snapshots pay off.
tomergee commentedon Nov 2, 2026
Another consumer, and two asks for the unified node-locality approach this thread wants.
In ai-on-gke/sandboxenv-rl we are planning a pre-flight that fills node image caches before an RL job (ai-on-gke/sandboxenv-rl#205): with placement image-blind, the first boot of each image pays the unpack on whatever node it lands on, and #3481's numbers (unpack 1 ms with the layers on the node, 9–50 s without, ~97 % of a cold first command) are what the job sees. The workaround available on main is client-side: WorkerPools as placement domains, each with its own label, and
Actor.worker_selectorper actor to keep an image's actors inside the domain that holds it. A scheduler preference like PR #298 would retire that.Until it lands, a client needs two things the API does not give today:
kubernetes.io/hostname, zone, node pool) intoWorker.labelsat registration, whichworker_selectorcan then name, or a per-actor node affinity composed into theRequiredNodesthe scheduler already has for local snapshots.Worker.status) lets a client verify a warm node and choose where to send an image's actors, and it is also how an operator would see a pre-warm took.Happy to write either up in more detail if it helps the unified design.
mansura-habiba commentedon Nov 18, 2026
Picking up the Phase 0 design note han2ni3bal-pixel offered above. I'd like to help write it, and I think it should also cover threads opened since June that touch the same code: #3528 (suspended actors are invisible to load), #589 / #3482 (what happens when the pinned node can't take the resume), and #3783 (placement cost grows with the fleet). A concept to react to before anyone writes code:
1. Keep the layered model and name the layers
I agree with fixed layers over a scoring framework. Proposed order per placement:
Applies/HasRoomCOMPLETEDInside each layer, keep power-of-two choices among the matching workers, so a preference narrows the pool without sending every resume to the one warm node.
Layer 1 is the substantive change. Today the pin is released only by detach (the timer, or a full node at resume time). Two cases slip through: a node whose worker is draining (Aditya Shantanu (@aditya-shantanu)'s test in #589 sees ~10 s of
ResourceExhaustedwhile another worker sits idle) and workers without limits, which never look full (#3479). Once the durable copy isCOMPLETED, the node can drop to a preference: a busy or draining node then costs a download, and the resume no longer fails. #2970's in-order attempts on the node fit inside this layer.2. Count suspended-but-bound actors as load (#3528)
Use them as the load signal inside each layer. They never count against capacity, so they can't block placement. Benjamin Elder (@BenTheElder), if the LRU mitigation for 1.1 lands first, this layer reads the same count.
3. Zone as the second topology level
Workers carry
node_nameand labels but no zone. Mirroring a small configured set of node labels (topology.kubernetes.io/zone, node pool) intoWorker.labelsat registration, as Tomer Glottmann (@tomergee) suggested above, gives layer 5 and lets operators define placement domains without one WorkerPool per node.4. Keep it cheap (#3783)
Index the worker cache by node (#3002) and by zone, so layers 1–5 look candidates up instead of scanning the fleet, and run the cheap checks before parsing
cpu_features(#3924).For the scans that remain (the detach pre-check #3810, the strict runtime pass #3779, a saturated fleet), cache “no room” results per constraint shape and scope (fleet, zone, node). Each cached “no” carries the generation of its scope. The worker cache bumps a generation only on events that can create room: a new worker, a worker turning ACTIVE, allocated going down, capacity going up, a new registered_epoch, or changed labels. Binds and deletes only remove room, so they leave cached results valid, which keeps the hit rate high under burst load. The bind’s admit check under the row lock stays as it is, so a cached answer can never cause a wrong bind. I’d ship it behind a flag in shadow mode first, counting disagreements with a real scan before enabling it.
Example: Anthropic's KubeCon NA scheduler talk reported sub-3 ms per placement at 65K nodes largely from that ordering.
5. Errors name the layer that failed
When every layer is empty,
ResourceExhaustedsays whether the pinned node was full or draining or the fleet was full, building on #398 / #401.Sequencing
I'm happy to write this up under
docs/and take items 2 and 3. Open questions for maintainers:AI disclosure: I used an AI assistant to survey the related issues and draft this note; the design and the positions are mine.
BenTheElder commentedon Nov 18, 2026
Please don't post huge AI comments, they cost a lot of time to read and consider, and they provide no signal as to your contribution.
The issue tracker is for us to discuss high level approaches and reach consensus, so it should be very high signal : noise ratio.
I'm not going to read through this the moment given how many other things we have going on.