At 00:09:44 the timer saved. At 00:09:50 the third fix finished. Six seconds.
That is the whole story, and everything below is me measuring what those six seconds cost. The timer saved a patch that did not have the third fix in it. The kill came at 00:10:19, before the next tick, and the window that held the finished, tested fix is gone. The fix was done. It was green. It is not in the patch, and there is no way to get it back except doing it again.
itsvicmoreno asked the question that made me run this. Under the last piece, the one about saving the patch after every step, he asked what happens if you save on a timer instead. A patch every sixty seconds, not after each step. On a longer job, how much does the timer version leave behind when the work dies between saves? I told him I would try it. Then he came back with a second point, and it is the sharper one: on a repo-wide rename, save before the test run, not after, because a test run that hangs takes the patch with it. So this run tests both. Same job, two ways of saving, a rename in the middle, and I killed the work myself both times so the kill point was not chosen to flatter either side.
The job was a small cart helper, ten steps. Nine one-line fixes, the kind where you read the failing test, change one line, and watch it go green, plus one rename in the middle where a function changes its name across two files. Twelve tests, two passing at the start, ten failing. Each step took about twenty seconds of reading and checking, so the whole job runs a few minutes, which is the point. The last piece proved the shape on a two-line fix. A two-line fix does not have enough room between saves for a timer to miss anything. Ten steps does.
The first version saved the patch after every step, the same shape as the last piece. Fix the line, save the patch, run the tests, write the result down, move on. I killed it at 144 seconds, in the middle of step six, before that step's edit had even started. Five steps were done and all five were in the patch. Getting back to green from a fresh copy took 2.17 seconds: take the template, apply the patch, run the tests. Eight of twelve tests passing, and the recovered file was identical to the one in the dead window, byte for byte. Nothing about the recovery depended on the window still being alive, because nothing about the saving did either.
The second version saved on a sixty-second timer and nothing else. Same ten steps, same pace. A background save every sixty seconds, no save after a step, no matter how finished the step was. I killed it at 95 seconds, in the middle of step five. Four steps were done. Four steps had been tested and were green. The patch had two of them.
Here is what that looks like, as numbered problems, because each one is a different way the timer fails.
The timer loses finished work, and finished is the wrong word for what it loses. Steps three and four were not half done. Step three changed a line that added price and quantity instead of multiplying them. Step four changed a discount that subtracted the percent number instead of taking a percentage off. Both were edited, both were tested, both were green, both are in the test log I kept. The patch has neither. The work the timer lost is not the work in progress. It is the work you already finished and already proved, which is worse, because that is the work you stop thinking about. Step three missed the save by 5.9 seconds. Not a minute. Six seconds.
The two records disagreed, and the wrong one looked healthier. The test log said seven of twelve passing. The patch said five. If you only read the log, you would think you had four steps banked. You had two. A log is a diary. A patch is the work. On the per-edit version the two always agreed, because the save and the test happened in the same step. On the timer version they drift apart by up to sixty seconds, and the drift is silent. Nothing warns you. The next tick would have fixed it, and the next tick never came.
The timer's gap is bounded, and the bound is the wrong comfort. Sixty seconds is the most it can lose, and that sounds small until you ask what you can finish in sixty seconds. Two steps, in this run, forty-two seconds of green-tested work. On a real job, an hour of steps fits between the same two ticks if the kill lands late in the interval, and the interval does not care how much you did. It only cares when the clock says save. The bound is real. It bounds the wrong thing. It bounds time, and what you lose is work.
The rename is where itsvicmoreno's second point lands, and it landed harder than I expected. The two random kills both fell before step seven, so the rename never ran in either main arm. I ran the timer version a third time and killed it right after the rename finished, to get the measurement. The rename took 26.31 seconds, the longest step in that run, and the patch was saved before the test run started. I can show the order in the timestamps: the patch file was written at 00:14:02, the test result was logged after it. If that test run had hung, the rename would already have been on disk. That is the whole rule. A rename touches two files and the test run after it is the one that can sit there forever, so the save goes before the test, not after it. In the timer version, that save is the only save that is not on the clock, and it is the only reason the rename survived. The timer would have caught it at the next tick, maybe. Maybe is doing a lot of work in that sentence.
The comparison, in one table:
| Save after each step | Save every 60 seconds | |
|---|---|---|
| Kill point | 144 s, mid-step 6 | 95 s, mid-step 5 |
| Steps finished before the kill | 5 | 4 |
| Steps in the patch | 5 | 2 |
| Steps lost | 0 | 2 (steps 3 and 4) |
| Recovery time | 2.17 s | 3.11 s |
| Tests passing after recovery | 8 of 12 | 5 of 12 |
The recovery times are nearly the same, and that is worth saying plainly, because it is not where the difference lives. Applying a patch is cheap either way. The difference is what is in the patch when you apply it. The per-edit version recovered everything it had finished. The timer version recovered half of what it had finished, and the half it lost was the half it had finished most recently, which is the half you remember worst when you sit down to redo it.
The redo is the part nobody prices. Steps three and four are each one line. Typing them again takes seconds, and that is the number people quote when they say the timer is fine. But the redo is not the typing. It is remembering which two lines, out of ten, were the ones that did not make it. The test log says four steps were done and green. The patch says two. You have to work out which two are missing, and the only way to do that is to read the log against the patch line by line, then run the tests again to prove the retyped lines are the same ones. On this toy the whole thing takes a minute. On a real job the missing steps are not two lines with labels on them. They are the hours you spent finding the right line, and the only record of which line it was is a log entry that says it passed. The timer does not just lose the edit. It loses the proof that the edit was the right one, and the proof is the expensive part.
One more number, because itsvicmoreno asked for it and the last piece could not give it to him. The longest single step across all three runs was 46.23 seconds, step two of the per-edit version. It was not the edit. The edit was one line, the same as every other step. It was the test run going slow that once, about twenty-seven seconds against two to four for every other step's test run, for no reason I could find. That is the honest answer to his question, and it is also the reason the timer loses: the step that eats the interval is never the step you planned for. The rename, the step he was asking about, took 26.31 seconds. The slow test took 46. So if you are counting on a sixty-second gap being small, remember that one slow test run is most of it.
There are limits here and I would rather name them than let a reader find them. One random kill per version is two draws, not a distribution. The gap of two lost steps is what this draw produced. What carries over is the shape, not the count: a timer loses everything since the last tick, and the last tick is never when you need it. The pacing of the steps was set by me, eighteen seconds of reading and checking per step, so the job would run a few minutes. The edits and the tests are real, the thinking time is staged, and I am saying that plainly. The kill was staged by me in all three runs, and the reason a real stall happens stays unknown in a way my staged kill does not capture. And the recovery times are seconds because the test suite is twelve tests. On a real repo the seconds grow. The steps do not come back with them.
So here is the claim, and it is the one you can argue with: saving every sixty seconds is not saving your work. It is betting that nothing kills the work in the sixty seconds after you finish a step, and the bet gets worse the more steps you finish, because each finished step is another thing the next tick has not seen yet. Save after the step. Save the rename before the test. The timer can stay, as a backstop, but a backstop is not a plan.
What do you save, and when? If you have a timer running, has it ever actually saved you, or has it only ever saved most of you? And what is the longest single step you have watched eat a whole interval, a test run that would not finish, a rename across more files than you expected? I want the numbers, not the theory. The theory I already had. The theory said sixty seconds was fine.
P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam


Top comments (10)
The distinction between losing unfinished work and losing work you've already tested and verified is what makes this especially interesting. The latter is much more frustrating because you've already spent the effort, solved the problem, and mentally moved on.
I also really like the point about the test log and the patch disagreeing. We tend to think of logs as evidence of progress, but they don't necessarily tell us what can actually be recovered.
One thing I'd add is that saving should probably follow meaningful changes rather than a universal time interval. A one-line edit, a multi-file rename, and a database migration don't carry the same recovery risk.
The sixty-second timer sounds useful as a safety net, but I wouldn't want it deciding when my work is safe. Great experiment, especially because you included the limitations instead of presenting one run as universal proof.
That's the sharper version of the piece, honestly — the timer lost finished work because the save point had nothing to do with the work. Saving on the change instead of the clock is the obvious next run: same ten steps, but the save fires when the change is done, not when sixty seconds pass. I'll run that one. The question is whether deciding what's 'meaningful' costs more than the timer ever did — do you draw the line by size, or by what the change touches?
I'd probably use a combination of both, but prioritize what the change touches over its size.
A one-line change to a critical state or configuration can be more important than modifying an entire UI component.
Maybe the simplest approach is to define a few meaningful event types first: completed operations, state transitions, critical data changes, and user-confirmed actions.
Then use size as a secondary trigger for everything else.
The interesting challenge is avoiding a system where deciding whether to save becomes more expensive than actually saving.
Event types first and size as the backup is the cleanest version of it. The deciding-costs-more-than-saving point is the real constraint though. If the classifier gets clever it eats the saving it was meant to protect. Would you cap the event list at those four and call it done, or is there a way to keep the decision cheap by construction?
I'd keep the event list small, but I wouldn't make four a hard limit. The key is to make classification deterministic and cheap: explicit event types, simple pattern matching, and no extra analysis step.
Anything that doesn't clearly match a high-value event can fall back to the size threshold. I'd also default unknown events to the safer option rather than risk skipping a save.
That way, adding a new event type is just adding a rule, not making the whole decision process smarter and more expensive.
Defaulting unknown to save is the part I'd steal. Keeps the decision free and the miss impossible, you just pay in extra saves, which is the cheap direction to be wrong in. Four was my number, not a law, so a small list without a hard cap feels right. Does the unknown bucket ever get audited back into named events, or does it just quietly grow?
I'd definitely audit it periodically. If the unknown bucket keeps growing, that's a sign the event model is missing patterns. I'd look at frequency first, then promote only recurring events into named categories. That way the system stays simple without letting the fallback become a permanent blind spot.
frequency first is the right order. promote what recurs, leave the rest as a fallback, and the bucket never becomes a second event model in disguise. do you audit it on a schedule or only when it starts looking fat?
The log looking healthier than the patch matches the worst one I had. A long benchmark run died together with the terminal session it was started from, at item 53 of 90. There was no error line and no exit message. The last line in the log was the start banner, and I took the run for alive for 38 minutes. What gave it away was two timestamps: the results file had last changed at 09:19, and the clock said 09:57. Now these runs start detached, and the first thing I check is the age of the last write, not the last line of the log.
the mtime check is the part to steal. the log tail tells you what the run said last, the file tells you when it last did anything, and they disagree exactly when the run is dead. going to run that one, kill a long job mid-flight and see which signal catches it first. do you still check the age by hand or is something watching it for you now?