Skip to content

perf(sandbox): mount org-fs volumes concurrently at daemon boot - #5333

Merged
pedrofrxncx merged 1 commit into
mainfrom
perf/org-fs-parallel-mount-w2
Jul 28, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
perf/org-fs-parallel-mount-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Source: reduction/optimization found while hunting the org-fs filesystem-abstraction area (issue #2884's focus area) — MountManager.start() in packages/sandbox/daemon/org-fs/mount-manager.ts.

Why: start() mounted each configured org-fs volume one at a time (for (...) await this.mountOne(m)), even though every volume is fully independent — its own OrgFsClient, its own loopback WebDAV server, its own rclone process and free port. Each mountOne can take real time (spawn rclone, then poll its rc vfs/list up to READY_TIMEOUT_MS = 15s in the worst case). A sandbox mounts at least 3 volumes today (home, outputs, uploads) plus one more per configured public skill set (buildOrgFsConfig in apps/api/src/file-storage/mount/provisioning.ts), so the sequential loop directly adds to sandbox boot latency the agent is blocked on — pure serialized network/process-spawn work with no ordering dependency between volumes.

Fix: mount all volumes concurrently with Promise.all(config.mounts.map((m) => this.mountOne(m))). mountOne already catches its own errors and is a self-contained "never throws, skip on failure" unit (each mount independently tries/logs/skips), so running them concurrently doesn't change failure semantics — a failing volume still just gets skipped, others still mount. this.active.push(entry) is a synchronous array push inside each async continuation, so no race there (JS is single-threaded). Total boot time now bounds to the slowest single mount instead of the sum of all of them.

Verify: cd packages/sandbox && bunx tsc --noEmit (clean) and bun test packages/sandbox/daemon/org-fs/mount-manager.test.ts (12 pass, unchanged — the tests already sort results before asserting, so they don't depend on mount order).

Local checks run: bun run fmt, targeted tsc --noEmit in packages/sandbox, and the single test file above. Full CI validates the rest.


Summary by cubic

Mount org-fs volumes concurrently during sandbox daemon boot to cut startup latency. Boot time is now limited by the slowest mount instead of the sum, aligning with #2884’s org-fs performance focus.

  • Performance
    • Switched sequential mounts to Promise.all in packages/sandbox/daemon/org-fs/mount-manager.ts; mounts run independently with unchanged failure semantics.

Written for commit c2d598f. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 28, 2026 15:38
@pedrofrxncx
pedrofrxncx merged commit 55fe633 into main Jul 28, 2026
15 of 16 checks passed
@pedrofrxncx
pedrofrxncx deleted the perf/org-fs-parallel-mount-w2 branch July 28, 2026 15:44
decocms Bot pushed a commit that referenced this pull request Jul 28, 2026
PR: #5333 perf(sandbox): mount org-fs volumes concurrently at daemon boot
Bump type: patch

- @decocms/sandbox (packages/sandbox/package.json): 1.24.2 -> 1.24.3
- deploy/helm/sandbox-env (chart 0.9.34) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.24.3

Deploy-Scope: both
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.

1 participant