Skip to content

perf(supervisor): look up route owners on demand instead of sending the pool route directory - #5888

Open
FrostGod wants to merge 1 commit into
mainfrom
perf/5783-route-owner-lookup/FrostGod
Open

FrostGod wants to merge 1 commit into
mainfrom
perf/5783-route-owner-lookup/FrostGod

Conversation

@FrostGod

@FrostGod FrostGod commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Supervisor updates no longer carry the cluster-wide route list. A shared supervisor asks the gateway for a route's owner only when a sandbox runtime reaches it for a route it doesn't own.

How it works

What each supervisor update carries:

flowchart LR
  subgraph Before
    G1[Gateway] -- "own sandboxes + every route in the pool<br/>(grows with the pool)" --> S1[Supervisor A]
  end
  subgraph After
    G2[Gateway] -- "own sandboxes only<br/>(at most 1024)" --> S2[Supervisor A]
  end
Loading

When a sandbox runtime reaches a supervisor that doesn't own it:

sequenceDiagram
  participant R as Sandbox runtime (route X)
  participant A as Supervisor A
  participant G as Gateway
  participant B as Supervisor B (owns X)
  R->>A: route X?
  Note over A: X is not mine
  A->>G: RouteLookup X (existing Attach stream)
  G-->>A: RouteOwner X = B (from memory, no DB)
  A-->>R: redirect to B
  R->>B: route X?
  B-->>R: accept
Loading

Related Issue

Closes #5783

Changes

  • Removed route_directory from AssignmentSnapshot (field reserved). A member's update now holds only its own sandboxes, so its size no longer grows with the pool.
  • Added RouteLookup / RouteOwner on the existing Attach stream. The gateway answers from its in-memory pool view, with no DB read.
  • The supervisor router only asks for routes it doesn't own:
    • Lookups are capped at 2s and 64 distinct routes.
    • A lookup is sent only while half the outbound queue is free, so heartbeats and status reports are never delayed.
    • With no answer, the supervisor falls back to the local route or replies "unknown", and the runtime tries the next address.
  • The gateway message cap now depends only on sandboxes per supervisor. The 131072 pool ceiling stays: it bounds the owner state each gateway holds and reads on every placement.
  • Dedicated supervisors are unchanged.

Testing

  • cargo clippy -D warnings on sandbox-backend, supervisor-control, supervisor, server, sandbox
  • Unit tests pass (supervisor, supervisor-control, sandbox-backend). New tests cover:
    • a member's update stays small when another member owns 131072 routes
    • only routes this member doesn't own are looked up
    • duplicate lookups share one request, a busy queue sends none, and disconnect releases waiters
  • Linux sandbox routing tests pass (all 7)
  • mise run proto:lint
  • Local k3d cluster with 1 gateway, 3 shared supervisors at 4 sandboxes each, and 10 sandboxes:
    • exec works in all 10
    • after a rolling restart of all supervisors, every sandbox moved to a new supervisor and exec still works in all 10
    • supervisors redirected 53 connections using gateway lookups
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

…he pool route directory

A pool member's assignment snapshot no longer carries every route in the
pool. A member asks the gateway for the owner of a route it does not own
(RouteLookup/RouteOwner on the existing Attach stream) only when a sandbox
runtime reaches it for that route, so a member's messages scale with its own
sandboxes rather than with the pool.

Closes #5783

Signed-off-by: divesh <dgude@nvidia.com>
@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. rust-sdk — No explicit risk acceptance found

Within openshell_sdk::raw::proto::supervisor_host::v1, AssignmentSnapshot loses route_directory and the previously exhaustive HostMessage/HostGatewayMessage payload enums gain RouteLookup/RouteOwner variants.

  • Impact: SDK adapters and mocks accessing or initializing route_directory or exhaustively matching either payload stop compiling; ordinary client calls and the Attach server-trait method set remain unchanged.
  • Action: Preserve the baseline SDK field and exhaustive payload enums for v0.1.10, isolating lookup messages in separate internal types or deferring the source-breaking transition to a permitted minor release with notice and migration guidance.
  • PR: perf(supervisor): look up route owners on demand instead of sending the pool route directory #5888
Review details
  • Execution: complete
  • Candidate: PR #5888 (4ffb3c7328cc335b5fe7399bf973ad9ec7d326b2)
  • Baseline: 38c47412dd7e94b8efc44b128940e097590b7582 (38c47412dd7e94b8efc44b128940e097590b7582)
  • Reviewed: rust-sdk, python-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(supervisor): stop sending the cluster-wide route list in every supervisor update

1 participant