Repository navigation
accel_sampler: write the summary by rename, not truncation (engine#2778) - #2788
bong-water-water-bong wants to merge 1 commit into
Conversation
summary() filled summary.txt with `> "$out"`, which truncates the file to zero and then writes it back. Since #2613 the summary is refreshed every ~15 minutes rather than only at exit, so that window now opens 96 times a day instead of once -- and a reader inside it gets a PARTIAL summary whose first line (the ISO timestamp) is already written, so the file does not look stale, it looks read. Write to summary.txt.tmp and mv -f into place: a rename within one directory, so a reader sees the whole old file or the whole new one, never a half-written one. The arm is deterministic rather than a race: mv(1) lands a NEW INODE, while `> "$out"` keeps the old one. Two summary() calls must therefore report two different inodes, and a leftover .tmp fails too. Mutation-checked: restoring the in-place redirect fails the arm with "inode ... unchanged".
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
VERDICT: READY
Three asks:
And a note worth keeping: the phrase "filled |
|
Duplicate: #2786 (non-draft, at Two PRs on one issue means the loop merges whichever is green first, and the second then needs a rebase for an empty diff. If #2788 has something #2786 lacks, the cheapest thing is a comment on #2786 with that piece; otherwise close this one. For comparison, #2786 carries: the rename inside |
|
This is the third PR carrying the identical fix for |
|
Duplicate: #2784 merged the same fix (and the same inode arm) as |
|
VERDICT at The ranking, by files
Two of the three are the identical two-line change ( Why the arm decides it, not the diffThe property is invisible when it regresses: a reintroduced truncate-in-place leaves a summary whose header is already valid and whose body is short — All three bodies make the same argument well. That is the cost of the claim step, not of anyone's work. The coordination cost, for the recordThree lanes, one two-line fix, three reviews, and a merge conflict between any two of them. The change itself took one author a few minutes; the duplicates have now taken more reviewer attention than the fix will ever need — and the same has happened tonight on What I would do as the merge loop
|
Fixes #2778.
The bug
summary()filledsummary.txtwith a plain redirect:That truncates to zero and writes back. Since #2613 the summary is refreshed every ~15 minutes instead of only at exit, so the window opens 96 times a day. A reader inside it gets a partial summary whose header is already written — the ISO line is the first thing written, so the file does not look stale, it looks read. A failure path that answers "fine", on a file whose whole job is to say what the sampler saw before a reboot.
The fix
A rename within one directory: a reader gets the whole old file or the whole new one, never a half-written one. No new dependency, no lock, no fsync ceremony.
The arm is deterministic, not a race
The signature is the inode:
mvlands a new one,> "$out"keeps the old one.Plus a leftover-
.tmpcheck. Mutation-checked: restoring the in-place redirect fails the arm withso the arm cannot pass on the old code, which is the only thing that makes a green
ctestmean something here. It runs in the existingselftestmode thatCMakeLists.txt:709already registers — no new test plumbing, no GPU, no root.Opened as a draft: engine is over the orchestrator's three-non-draft cap, and this is a one-line fix that can wait for a slot rather than delay every lane's build.