fix(core): make recursive mkdir a single write-side op (no per-component exists walk)#1532
Merged
Merged
Conversation
`AgentOs.mkdir(path, { recursive: true })` (_mkdirp) probed every ancestor
with a read-side `exists()` before each `mkdir`. On the native sidecar every
read-side fs op triggers a full shadow-tree reconciliation walk, so a
per-component `exists()` loop makes `mkdir -p` cost O(components * tree) and is
a major contributor to session-creation latency on populated VMs. The kernel
`mkdir` is already recursive and creating an existing directory is a no-op, so a
single call is sufficient.
Adds a regression test asserting recursive mkdir issues exactly one `mkdir` and
zero `exists()` probes, while preserving behavior (intermediate dirs created,
idempotent).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
rivet-frontend / agentos-pr-1532
June 25, 2026 12:09
Destroyed
|
🚅 Deployed to the agentos-pr-1532 environment in agentos
🚅 Deployed to the agentos-pr-1532 environment in rivet-frontend
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AgentOs.mkdir(path, { recursive: true })(_mkdirp) probed every ancestor with a read-sideexists()before eachmkdir:On the native sidecar every read-side fs op (
exists/stat/readFile) triggers a full shadow-tree reconciliation walk in secure-exec. So a per-componentexists()loop makesmkdir -p /a/b/c/dcost O(components × whole-shadow-tree) — a major contributor to the session-creation latency seen on populated VMs (eachmkdirstep paying a multi-second walk).Fix
kernel.mkdiralready defaults to recursive on both the native sidecar and compat kernels, and creating an existing directory is a no-op, so a single write-side call is sufficient (write-side ops skip the walk):Test
Adds a regression test (
recursive mkdir issues one mkdir and zero exists() probes) asserting recursive mkdir issues exactly onemkdirand zeroexists()probes, while preserving behavior (all intermediate dirs created and writable, idempotent on repeat).