Skip to content

perf(runner): implement vsock for host-guest communication #1163

@lancy

Description

@lancy

Summary

Replace SSH-based host-guest communication with virtio-vsock for lower latency and faster VM readiness detection.

Problem

Current SSH-based communication has several overheads:

  • 2-second polling interval for readiness detection
  • 10-second connect timeout per attempt
  • TCP/IP stack overhead inside VM
  • SSH protocol handshake overhead

This adds ~3-5 seconds to each VM startup.

Proposed Solution

Use virtio-vsock for direct host-guest communication channel.

Benefits

  • No TCP/IP stack required
  • No SSH handshake
  • Instant readiness notification (no polling)
  • Lower latency for all host-guest operations

Technical Approach

  1. Configure Firecracker with vsock device
  2. Create vsock listener on host
  3. Create vsock client agent in guest rootfs
  4. Replace SSH client with vsock client in executor
  5. Implement readiness signal via vsock

Key Files

  • turbo/apps/runner/src/lib/firecracker/vm.ts - Add vsock config
  • turbo/apps/runner/src/lib/firecracker/client.ts - Add vsock to API calls
  • turbo/apps/runner/src/lib/firecracker/guest.ts - Replace SSH with vsock
  • turbo/scripts/deploy-runner/Dockerfile - Add vsock agent

Expected Impact

  • Time saved: ~3-5 seconds per VM startup
  • Latency: Faster command execution within VM

Considerations

  • Requires kernel support in guest (virtio-vsock module)
  • Need to develop vsock-based agent for guest
  • Significant architectural change
  • Can fallback to SSH if vsock unavailable

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions