Repository navigation
A worktree seed leaves a fifth of the disk free and logs a skipped copy (#419) - #420
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7350e3217
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let after = space.free.saturating_sub(size); | ||
| let fits = space.free >= size.saturating_mul(2) | ||
| && after as f64 >= SEED_MIN_FREE_SHARE * space.total as f64; |
There was a problem hiding this comment.
Serialize seed reservations before enforcing the free-space floor
When multiple fresh worktrees are seeded concurrently, each SyncProbe runs in its own connection task and can read the same pre-copy free-space value, so every copy can pass this check even though their combined allocation violates the 20% floor. With the commit's 980 GB example, three simultaneous 48 GB seeds can all observe 290 GB free, each compute 242 GB remaining, and ultimately leave only 146 GB (14.9%), crossing the janitor threshold this change is intended to avoid. Reserve the bytes atomically or serialize the capacity check and copy across seed operations.
Useful? React with 👍 / 👎.
Problem
A seed copied the main copy's whole
target/debuginto every new worktree copy whenever twice its size was free (#419). For this repository on a build node that was 48 GB in 571,304 files. Three short-lived worktrees (46 GB, 46 GB, 48 GB) took 140 GB within an hour and left the 980 GB disk at 16% free, near the janitor's 15% prune line (#386). On a disk with 150 GB free the rule would still copy 48 GB and leave 10%.seed_dependency_trees(#412, #414) used the same rule.Change
seed_fits(what, size, space)decides for both seeds. It requires twice the size free, as before, and at least 20% of the filesystem (SEED_MIN_FREE_SHARE) free after the copy. That keeps seeding above the janitor's 15%, so a seed never forces pruning or the disk pressure that placement avoids (Placement ignores memory and disk: a node out of space or memory still gets new workspaces #396).🌱 [SEED] skipped: the copy would leave too little disk free, withwhat,size_mb,free_mbandtotal_mb. A slow first build in a worktree can then be told apart from a bug.free_disk_bytesbecomesdisk_space, which returns free and total bytes fromstatvfs.With the numbers above (980 GB, 290 GB free after the cleanup), the next 48 GB seed still happens (242 GB, 24.7% left) and the one after it is skipped (194 GB would be 19.8%).
Reproduce and verify
The three copies of worktrees that no longer existed were removed by hand (150 GB free before, 290 GB after).
a_seeded_copy_goes_without_a_build_cache_it_has_no_room_fornow also checks the share rule. A 1,000-byte cache with 10,000 free is skipped on a 46,000-byte filesystem (9,000 left, under a fifth) and copied on a 44,000-byte one. It also checks thatdisk_spacereports a total at least as large as the free space. On the old rule the 46,000 case would have copied. The other seed tests useroomy()/space(free, total).Most of the 48 GB is stale split-DWARF files (565,488
.dwo, 26.2 GB), filed separately.Checks
On a Linux build node:
prod-code validate --diff --compile: 0 errors, 0 warnings.Closes #419