Skip to content

Keep less memory per file a mount is asked about - #188

Merged
lydakis merged 1 commit into
mainfrom
claude/project-thread-dorvpr
Oct 28, 2026
Merged

lydakis merged 1 commit into
mainfrom
claude/project-thread-dorvpr

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Requested by George · project thread

What changed

George's priority is keeping the mount's RAM as low as possible. A walk of a 200k-file folder (find then ls -lR) made the mount process hold 147 MB, about 740 bytes per path. A heap profile at 20k files put 33% in the inode table, 24% in the core's path-to-entry cache, 22% in listings and 11% in path-to-inode. This PR trims the first two and caps one cache.

  • Core path-to-entry cache (workspace.rs): only directories are kept. Files far outnumber them, and a file is found in its directory's listing, one lookup more. The cache's keys share the entry's own key bytes when they're the same path, as in a folder.
  • Recheck (workspace.rs): with files out of that cache, rechecking a shrunk file (Never pad a file that shrank under a mount with zeros #186) changes only its listing, so patch_listing loses its closure.
  • Inode table (fs.rs): the rarely set removed_from is boxed, and the table shrinks once the kernel has forgotten most of it (capacity over 4096, length under a quarter).
  • Git mounts (fs.rs): recent whole-file reads are capped at 64 MiB instead of 256 MiB.

Measured on Linux FUSE, release build, 200k files, mount process anonymous memory:

main this PR
after find + ls -lR 147 MB 89 MB
after the kernel forgets inodes 148 MB 77 MB

Walk times are unchanged. What's freed goes back to the system on the musl release builds; glibc keeps it for reuse. The workspace forbids unsafe code, so the mount doesn't call malloc_trim. macOS isn't measured yet.

API changes

None.

Tests

  • cargo test --workspace --no-fail-fast passes here, except the two sandfs shell tests that need bubblewrap, which isn't installed in this container.
  • cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check are clean.


Generated by Claude Code

Box the rarely set removed_from of each inode, keep only directories in
the core's path-to-entry cache (files are one listing lookup further),
share that cache's keys with the entries' own, shrink the inode table
once the kernel forgets most of it, and cap a git mount's recent whole
file reads at 64 MiB. A 200k-file walk goes from 147 MB to 89 MB with
the same walk times. With files out of the path-entry cache, a recheck
of a shrunk file changes only its listing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGETmgGUb8hcSEpppQK
@lydakis lydakis self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T01:08:15.224938Z 80a4e70 PR opened
🔒 Security Review ✅ Completed 2026-10-28T01:09:25.190405Z 80a4e70 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lydakis
lydakis merged commit de0fadc into main Oct 28, 2026
23 checks passed
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.

2 participants