Repository navigation
feat(platform): add durable writes, locks and file clones - #9
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PiquelChips
force-pushed
the
feat/platform
branch
from
October 18, 2026 17:50
1bd0c07 to
47bb72b
Compare
PiquelChips
force-pushed
the
feat/platform
branch
from
October 18, 2026 17:59
47bb72b to
f48fbe7
Compare
PiquelChips
force-pushed
the
feat/platform
branch
from
October 28, 2026 20:33
f48fbe7 to
944ee19
Compare
PiquelChips
force-pushed
the
feat/platform
branch
3 times, most recently
from
November 2, 2026 23:34
d853f93 to
2a3f22d
Compare
PiquelChips
force-pushed
the
feat/platform
branch
from
November 4, 2026 17:58
2a3f22d to
0d31182
Compare
PiquelChips
force-pushed
the
feat/platform
branch
from
November 4, 2026 18:22
0d31182 to
b5e9b43
Compare
PiquelChips
force-pushed
the
feat/platform
branch
from
November 4, 2026 18:33
b5e9b43 to
5465bc9
Compare
Storage needs four things the platforms do differently: syncing data and directories to stable storage, file locks the kernel releases when a process dies, copy-on-write clones, and telling local file systems from network ones. origin-platform puts each behind a trait (Durability, FileLock, CloneFile, FileSystem) with Linux and macOS modules, and a single cfg_select! picks the module and the Native alias for the build target. A conformance suite runs against Native, including a lock held by a child process that is killed. DurableWrite is the write sequence the store will use: each file is written under a temporary name beside its destination without syncing, then a commit makes the whole batch durable with one Durability::sync_batch, renames the group into place from several threads and syncs each directory involved once. Staging beside the destination keeps renames into different directories from contending on one shared temporary directory, and DurableWrite::is_temporary lets readers skip, and clean up, the `.tmp-` files a crash leaves behind. On Linux the batch is one syncfs (a lone file is fdatasync'd, which is cheaper); on macOS it is a plain fsync per file and a single F_FULLFSYNC, as SQLite does. A 128-file batch drops from about 390 ms to 17 ms. FileSystem classifies the file system holding a path with statfs, and check_writable refuses network ones (NFS, SMB, AFP, 9p, ...) with an error naming them. Dropbox and iCloud folders sit on local file systems and can't be detected this way.
PiquelChips
force-pushed
the
feat/platform
branch
from
November 4, 2026 18:34
5465bc9 to
cb5fd31
Compare
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.
Storage needs four things that work differently on each platform:
Without one place for this,
cfgs would end up scattered everywhere.crates/origin-platformputs each behind a trait:Durability,FileLock,CloneFile,FileSystem. Linux and macOS each get a module, and a singlecfg_select!picks one by build target. That is the only place the code depends on the OS. A conformance suite runs against the native implementation, including a lock held by a child process that gets killed.DurableWriteis the write sequence every later PR uses. Files are staged beside their destination without syncing. Then one batch sync covers them all:syncfson Linux (orfdatasyncfor a single file), andfsyncper file plus oneF_FULLFSYNCon macOS. The files are then renamed into place from several threads, and each directory is synced once. A directory created by a batch has its parent synced at once, even if the batch is abandoned.FileSystem::check_writablerefuses network file systems (NFS, SMB, AFP, 9p…) with an error naming them. Dropbox and iCloud folders sit on local file systems, so they can't be detected this way.unsafe. System calls come from std,rustixandreflink-copy.rustixandreflink-copywere approved as dependencies.Benchmarks: a 128-file batch takes 17 ms, against 390 ms when every file is synced, and an uncontended lock takes 3.3 µs.
Note
Written by Claude Opus 5.5 in Claude Code, reviewed by GPT-6.1 Sol and Claude Opus 5.5 over three review rounds (via T3 Code).
🤖 Generated with Claude Code