Commit 3c631dc
committed
state, internal/dao, util: revert hot-path fsync, fix leak and doc inaccuracy
- util.AtomicWriteFile: drop the fsync added last round. On macOS, Go's
File.Sync issues fcntl(F_FULLFSYNC), which measured ~140x slower than the
plain write here (confirmed on this machine: ~4.3ms vs ~30µs/op) -- and this
helper runs on Hermit's "exec" hot path via dao.UpdatePackage. The data it
protects is a regenerable cache (etag + check timestamp), so losing it to a
crash just costs one extra upstream check; that's not worth paying this cost
on every invocation. Documented as a deliberate omission.
- state.extract: the "copy manifest referred files" loop can also fail after
archive.Extract has already published p.Dest, the same condition the
previous commit fixed for the EventUnpack trigger a few lines below it --
missed because it wasn't the line called out by review. Now cleaned up with
util.RemoveAllAtomic here too, otherwise a retry of the same package is
permanently wedged behind archive.Extract's "destination already exists".
- internal/dao.UpdatePackage: correct a doc comment claiming the etag/
checked-at interleave risk was "not introduced by the two-file split" --
the single-JSON-file format it replaced wrote both fields in one atomic
rename, so this specific mismatched pairing is in fact newly possible.
Still benign: worst case is a one-cycle-stale check time that self-corrects.1 parent 3a56197 commit 3c631dc
3 files changed
Lines changed: 25 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
457 | 464 | | |
458 | 465 | | |
459 | 466 | | |
460 | 467 | | |
| 468 | + | |
461 | 469 | | |
462 | 470 | | |
463 | 471 | | |
464 | 472 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
14 | 25 | | |
15 | 26 | | |
16 | 27 | | |
| |||
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
0 commit comments