Skip to content

perf(sandbox): block in poll(2) while the boundary is idle - #6148

Open
FrostGod wants to merge 2 commits into
mainfrom
perf/6071-boundary-poll-wait/FrostGod
Open

FrostGod wants to merge 2 commits into
mainfrom
perf/6071-boundary-poll-wait/FrostGod

Conversation

@FrostGod

@FrostGod FrostGod commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

An idle sandbox boundary woke every 10 ms to check its termination flag. It now sleeps in poll(2) until a SIGTERM/SIGINT arrives or, in listener mode, a connection is pending. In a microVM each of those wakeups is a VM exit.

Related Issue

Closes #6071

Changes

  • The SIGTERM/SIGINT handler also writes to a nonblocking, close-on-exec self-pipe.
  • The listener and runtime-initiated loops wait in poll(2) on that pipe (plus the listener fd) instead of sleep(10ms), with a 1 s fallback timeout.
  • Installing the handlers drains any stale wakeup so a reused pipe cannot turn the idle wait into a busy loop.

Testing

Measured on a Docker-backed gateway (Linux 6.8, arm64) with an idle sandbox. Wakeups are context switches across all boundary threads over 10 s.

Boundary Wakeups/s docker stop (SIGTERM)
main 91 0.06 s, exit 0
This branch 4 0.06 s, exit 0

An unrelated idle sandbox on the same host stayed at about 97 wakeups/s in both runs.

  • openshell-sandbox boundary_server tests pass on Linux (69 passed), including the new pending-connection wakeup test; cargo fmt and clippy -D warnings (with perf-harness) are clean
  • Docker conformance suite against this branch's sandbox image: 77 passed
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

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

- Replace the 10 ms sleep loops with poll(2) on a self-pipe.
- Signal handler writes to the pipe to wake the wait.
- Listener mode also wakes on a pending connection.
- Idle microVM cost: ~2.5% to ~0.2% of a core.

Closes #6071

Signed-off-by: Divesh <dgude@nvidia.com>
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 Dec 1, 2026

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(sandbox): idle boundary wakes every 10 ms

1 participant