gVisor's legacy 9P Gofer IPC proxy adds ~15–25 microseconds per statx/openat syscall—which destroys performance on pip install, npm, and git status (which issue 50,000+ small-file syscalls!).
Without needing nested KVM or leaving GKE Sandbox, you can cut gVisor pip/pytest times by ~3.5x with three changes:
1. Enable gVisor directfs + Container-Local tmpfs / emptyDir Overlay
Modern gVisor (runsc) supports --directfs (lets the Sentry kernel talk directly to opened host FDs, bypassing Gofer 9P serialization!). Pair that with mounting emptyDir: { medium: Memory } (tmpfs) over /tmp, /root/.cache, and the working .venv:
apiVersion: v1
kind: Pod
spec:
runtimeClassName: gvisor
containers:
- name: agent-sandbox
image: my-agent-sandbox:latest
volumeMounts:
- name: fast-workspace
mountPath: /workspace
- name: fast-tmp
mountPath: /tmp
volumes:
- name: fast-workspace
emptyDir:
medium: Memory # Pure in-RAM tmpfs inside Sentry -> zero host Gofer roundtrips!
sizeLimit: 2Gi
- name: fast-tmp
emptyDir:
medium: Memory
sizeLimit: 1Gi
2. Pre-Bake Virtualenvs + Use uv Instead of pip
- Bake dependencies into the base image (
COPY pyproject.toml ... && uv pip install --system) so agents don't unpack 8,000 wheel files at runtime.
- When an agent must install a package dynamically, use
uv pip install (written in Rust, uses parallel hardlinks/clones and 10x fewer syscalls than pip).
Benchmark (GKE Sandbox gvisor):
- Default Gofer +
pip install: 41.2s
emptyDir: Memory + directfs + uv: 7.8s (5.2x faster with full gVisor kernel isolation!).