fix(#146): fallocate memory.bin before BRANCH — flattens pause_ms across the chain#152
Merged
Merged
Conversation
…balloc 5 rounds of probe (#128, #140, #143, #150, #151) traced the multi-BRANCH pause_ms anomaly to ext4 delayed allocation + writeback throttle + multi-block allocator + block-bitmap CRC compounding per BRANCH. tmpfs control confirmed: anomaly is 100% in the fs layer. Fix: posix_fallocate the destination memory.bin to source full size right after we create snap_dir, before either the diff-mode background copy OR FC's snapshot/create write. ext4 reserves the extents up-front; subsequent writes don't run mballoc or update block bitmap. Best-effort — on tmpfs / unsupported FS the syscall returns ENOSYS, we log at WARN and continue (no behavior change). On ext4 (the actual problem case), this should flatten pause_ms across the BRANCH chain. Adds libc 0.2 as a cfg(unix) dep for posix_fallocate. Refs #146. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
WaylandYang
added a commit
that referenced
this pull request
May 23, 2026
Bumps Cargo workspace + Python SDK 0.3.3 → 0.3.4. After 5 probe rounds traced the multi-BRANCH pause_ms anomaly to ext4's delayed allocation + writeback throttle + multi-block allocator + block-bitmap CRC, PR #152 fixed it with a single posix_fallocate call. Measured impact: ext4 SSD, 10 consecutive diff BRANCHes: BRANCH 6 pause_ms: 2700 → 153 (17.6×) median BRANCH 3-10: ~1700 → ~200 ms (~8.5×) This is the first release that should auto-publish to PyPI via the new release.yml → publish-pypi.yml chain (PR #144). v0.3.1-0.3.3 all required manual workflow_dispatch. Full notes in CHANGELOG.md § 0.3.4. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 23, 2026
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.
Summary
Closes #146. The multi-BRANCH pause_ms anomaly (~5× jump from BRANCH 3+) was traced over 5 probe rounds to ext4's delayed allocation + multi-block allocator + writeback throttle + block-bitmap checksumming compounding per BRANCH. This PR is the one-shot fix: `posix_fallocate` the destination memory.bin to its full size before either the diff-mode background `std::fs::copy` or FC's `/snapshot/create` writes to it.
Before / after (live, ext4 SSD, `coding-agent-fork-prewarm-v1` source, 10 consecutive diff BRANCHes, 3 s gap)
Implementation
`posix_fallocate(fd, 0, source_memory_bin_size)` on the destination right after `mkdir snap_dir`. The pre-allocated extents are claimed by ext4 immediately; subsequent writes don't run `ext4_mb_new_blocks` and don't update on-disk block bitmaps in-band.
Best-effort: failure (tmpfs, NFS, FAT, EOPNOTSUPP, etc.) is logged at WARN and the BRANCH continues with the old behavior. No behavior change on filesystems that don't benefit.
Files
Refs
🤖 Generated with Claude Code