An open-source, faster Devin alternative
TypeScript
VM-DO: pre-warm the DO channel at pool manufacture
Brian Reardon08e88fc6d6d7
diff --git a/internal/api/pool.go b/internal/api/pool.goindex e512e76a..b238360f 100644--- a/internal/api/pool.go+++ b/internal/api/pool.go@@ -13,6 +13,7 @@ import ("github.com/google/uuid"+ "github.com/opensandbox/opensandbox/internal/auth""github.com/opensandbox/opensandbox/pkg/types"pb "github.com/opensandbox/opensandbox/proto/worker")@@ -105,6 +106,12 @@ func (s *Server) manufacturePoolBoxOn(ctx context.Context, workerID, region, temSandboxId: sandboxID,Template: template,Pooled: true,+ // Deliver the VM-DO connect token at manufacture so the worker host can+ // pre-warm the DO channel BEFORE the box is claimed. The token is a pure+ // HMAC(secret, id) — no claim/org needed — so the sandbox's first exec+ // after claim is DO-served instead of racing the ~100-500ms dial and+ // falling back to the tunnel. Claim re-sends the same token (idempotent).+ VmdoConnectToken: auth.MintVMDOConnectToken(s.sessionJWTSecret, sandboxID),})if err != nil {_ = s.store.WipePooled(ctx, sandboxID) // roll back the reserved rowdiff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.goindex eb862b0b..cf0a6769 100644--- a/internal/worker/grpc_server.go+++ b/internal/worker/grpc_server.go@@ -402,6 +402,12 @@ func (s *GRPCServer) CreateSandbox(ctx context.Context, req *pb.CreateSandboxReqs.router.Register(sb.ID, 0) // persistent — no idle timeout while parkeds.router.MarkPooled(sb.ID)}+ // Pre-warm the VM-DO exec channel now, while the box is still an unclaimed+ // pool entry, so the sandbox's FIRST exec after claim is DO-served rather+ // than racing the dial. The token is delivered even for pooled manufacture+ // (it's a pure HMAC(secret, id), no claim needed); ClaimSandbox re-issues+ // start() with the same token — a no-op since this dialer is already live.+ s.doDialers.start(sb.ID, req.VmdoConnectToken)log.Printf("grpc: manufactured pool box %s (template=%s) — %s", sb.ID, cfg.Template, parked)return &pb.CreateSandboxResponse{SandboxId: sb.ID,