Skip to content

Commit 6fd4106

Browse files
iamjr15claude
andcommitted
perf: remove Daytona volumes to reduce agent initiation latency
The volume feature was adding significant latency (up to 60s polling wait) during sandbox creation. Volumes were being used for npm/pnpm cache but the latency trade-off wasn't worth it. Changes: - Remove VolumeMount import from sandbox.py - Remove enable_cache_volumes parameter and volume setup code - Remove enable_cache_volumes=True call from agent/api.py - Delete volumes.py module entirely 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 612d468 commit 6fd4106

File tree

3 files changed

+1
-274
lines changed

3 files changed

+1
-274
lines changed

backend/agent/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,6 @@ async def initiate_agent_with_files(
11781178
project_id,
11791179
snapshot=snapshot_name,
11801180
account_id=account_id,
1181-
enable_cache_volumes=True # Enable npm/pnpm cache volumes for faster installs
11821181
)
11831182
sandbox_id = sandbox.id
11841183
logger.info(f"Created new sandbox {sandbox_id} for project {project_id} with snapshot {snapshot_name}")

backend/sandbox/sandbox.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
SessionExecuteRequest,
77
Resources,
88
SandboxState,
9-
VolumeMount,
109
)
1110
import asyncio
1211
from typing import Optional, Dict, Any, List
@@ -246,19 +245,17 @@ async def create_sandbox_from_snapshot(
246245
custom_labels: Optional[Dict[str, str]] = None,
247246
auto_stop_interval: int = 15,
248247
auto_archive_interval: int = 24 * 60,
249-
enable_cache_volumes: bool = False,
250248
) -> AsyncSandbox:
251249
"""Create a new sandbox from a snapshot optimized for development.
252250
253251
Args:
254252
project_id: Project identifier for tracking
255253
snapshot: Snapshot name to create sandbox from
256-
account_id: User account ID for resource tracking and volume management
254+
account_id: User account ID for resource tracking
257255
resource_tier: Resource tier ('light', 'standard', 'heavy')
258256
custom_labels: Additional labels to apply to sandbox
259257
auto_stop_interval: Minutes of inactivity before auto-stop (0 to disable)
260258
auto_archive_interval: Minutes after stop before auto-archive
261-
enable_cache_volumes: If True and account_id provided, attach npm/pnpm cache volumes
262259
263260
Returns:
264261
AsyncSandbox instance
@@ -297,35 +294,11 @@ async def create_sandbox_from_snapshot(
297294
resources = RESOURCE_TIERS.get(resource_tier, RESOURCE_TIERS["standard"])
298295
logger.debug(f"Using resource tier '{resource_tier}': cpu={resources.cpu}, memory={resources.memory}GB, disk={resources.disk}GB")
299296

300-
# Optionally attach cache volumes for npm/pnpm package caching
301-
volume_mounts: Optional[List[VolumeMount]] = None
302-
if enable_cache_volumes and account_id:
303-
try:
304-
from sandbox.volumes import volume_manager
305-
306-
logger.info(f"Setting up cache volumes for account {account_id}")
307-
cache_mounts = await volume_manager.get_cache_volume_mounts(account_id)
308-
309-
if cache_mounts:
310-
volume_mounts = [
311-
VolumeMount(
312-
volume_id=mount["volumeId"],
313-
mount_path=mount["mountPath"]
314-
)
315-
for mount in cache_mounts
316-
]
317-
logger.info(f"Attaching {len(volume_mounts)} cache volumes to sandbox")
318-
except Exception as vol_error:
319-
# Volume attachment is optional optimization - don't fail sandbox creation
320-
logger.warning(f"Failed to set up cache volumes (continuing without): {vol_error}")
321-
volume_mounts = None
322-
323297
params = CreateSandboxFromSnapshotParams(
324298
snapshot=snapshot,
325299
public=True,
326300
labels=labels,
327301
resources=resources,
328-
volumes=volume_mounts,
329302
env_vars={
330303
# Development environment variables
331304
"NODE_ENV": "development",

backend/sandbox/volumes.py

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)