Skip to content

perf(ssh,modal): bulk file sync via tar pipe and tar/base64 archive#7558

Closed
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:perf/ssh-bulk-upload
Closed

perf(ssh,modal): bulk file sync via tar pipe and tar/base64 archive#7558
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:perf/ssh-bulk-upload

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wire bulk_upload_fn into SSH and Modal backends, matching the pattern established for Daytona in #7538. Eliminates per-file transfer overhead during FileSyncManager.sync().

Also extracts shared helpers into file_sync.py and migrates _ensure_remote_dirs to use them.

Changes

Shared (tools/environments/file_sync.py)

  • quoted_mkdir_command() — mirrors existing quoted_rm_command()
  • unique_parent_dirs() — deduplicates parent directories from (host, remote) pairs

SSH (tools/environments/ssh.py)

  • _ssh_bulk_upload(): symlink-staging directory mirroring the remote layout, piped through tar -ch | ssh tar x in a single TCP stream
  • Pre-creates all parent dirs in one SSH mkdir -p call
  • Uses ControlMaster socket (same as existing _scp_upload)
  • Handles: mkdir failure (raises), tar create failure (raises), SSH extract failure (raises), timeout (kills both processes), SSH Popen failure (kills tar)
  • Migrates _ensure_remote_dirs to use shared helpers

Modal (tools/environments/modal.py)

  • _modal_bulk_upload(): builds an in-memory gzipped tar archive, base64-encodes it, decodes+extracts in one exec call
  • Pre-creates parent dirs in the same command (single exec call total)
  • Uses 120s timeout for bulk (vs 15s for per-file)
  • Checks exec exit code and raises on failure

Tests

  • test_ssh_bulk_upload.py — 21 tests across 4 classes: tar pipe mechanics (14), FileSyncManager wiring (1), shared helpers (6), edge cases (1)
  • test_modal_bulk_upload.py — 7 tests: empty noop, tar archive contents, mkdir coverage, single-exec verification, exit code error, FileSyncManager wiring, timeout

Backend status

Backend Upload method Bulk support Status
Daytona SDK upload_files() #7538 Already merged
SSH tar -ch | ssh tar x ✔ this PR New
Modal tar+base64 | exec ✔ this PR New
Docker Bind mount N/A No sync needed
Singularity Bind mount N/A No sync needed

28 new tests, all passing. Existing file_sync, SSH, and Modal tests unaffected (72 passed, 11 skipped integration).

Supersedes #7560.

Closes #7465
Closes #7467

SSH: symlink-staging + tar -ch piped over SSH in a single TCP stream.
Eliminates per-file scp round-trips. Handles timeout (kills both
processes), SSH Popen failure (kills tar), and tar create failure.

Modal: in-memory gzipped tar archive, base64-encoded, decoded+extracted
in one exec call. Checks exit code and raises on failure.

Both backends use shared helpers extracted into file_sync.py:
- quoted_mkdir_command() — mirrors existing quoted_rm_command()
- unique_parent_dirs() — deduplicates parent dirs from file pairs

Migrates _ensure_remote_dirs to use the new helpers.

28 new tests (21 SSH + 7 Modal), all passing.

Closes NousResearch#7465
Closes NousResearch#7467
@kshitijk4poor kshitijk4poor changed the title perf(ssh): bulk file sync via tar pipe instead of per-file scp perf(ssh,modal): bulk file sync via tar pipe and tar/base64 archive Apr 11, 2026
@alt-glitch alt-glitch self-assigned this Apr 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Salvaged in #8014 — cherry-picked your commit onto current main with authorship preserved. Added a follow-up commit fixing a critical Modal ARG_MAX bug (the base64 payload was embedded in the command string, exceeding Modal SDK's 64KB exec-arg limit — rewrote to pipe through proc.stdin), plus minor cleanup (removed narrating comments, deduplicated Daytona helpers). Thank you for the contribution @kshitijk4poor!

@alt-glitch alt-glitch closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: bulk file sync for all remote backends (SSH, Modal, Daytona) perf(ssh): bulk file sync via tar pipe instead of per-file scp

2 participants