Cause. The flush loop skipped a tick unless one interval had passed since the last write ended. The next tick came a little less than one interval after that. So the prefix handler wrote about every 2 seconds, and the AS and peer handlers about every 4.
Change.
Every tick of the timer writes.
A full batch's write restarts the timer as it begins, so the next timed write comes one interval after that write began.
A full batch still wakes the loop at once, and a waiting stop still goes first.
flushBatch no longer reports whether it wrote a batch. Only the old check read that.
TestFlushLoopWritesOnEveryTick runs flushLoop in a testing/synctest bubble, whose clock is fake. It fails on the old code.
Worth knowing.time.Sleep in the test only moves the bubble's fake clock. Ticker.Reset drops a tick already waiting in the channel, which the loop relies on; Go has guaranteed this since 1.23.
Judgement call: the brief said to record the time a write starts and compare it at each tick. Two ticks one interval apart can reach the loop a hair less than one interval apart, so that comparison would still skip some ticks. Restarting the timer needs no comparison.
Unverified: that tick timing claim is reasoning, not measured.
Not changed: TestPrefixHandlerWritesTheTableChangesEachSecond still waits on the real one-second timer, as before. It tests that timer.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/routewatch/issues/192.
**Cause.** The flush loop skipped a tick unless one interval had passed since the last write ended. The next tick came a little less than one interval after that. So the prefix handler wrote about every 2 seconds, and the AS and peer handlers about every 4.
**Change.**
- Every tick of the timer writes.
- A full batch's write restarts the timer as it begins, so the next timed write comes one interval after that write began.
- A full batch still wakes the loop at once, and a waiting stop still goes first.
- `flushBatch` no longer reports whether it wrote a batch. Only the old check read that.
- `TestFlushLoopWritesOnEveryTick` runs `flushLoop` in a `testing/synctest` bubble, whose clock is fake. It fails on the old code.
**Worth knowing.** `time.Sleep` in the test only moves the bubble's fake clock. `Ticker.Reset` drops a tick already waiting in the channel, which the loop relies on; Go has guaranteed this since 1.23.
Judgement call: the brief said to record the time a write starts and compare it at each tick. Two ticks one interval apart can reach the loop a hair less than one interval apart, so that comparison would still skip some ticks. Restarting the timer needs no comparison.
Unverified: that tick timing claim is reasoning, not measured.
Not changed: `TestPrefixHandlerWritesTheTableChangesEachSecond` still waits on the real one-second timer, as before. It tests that timer.
Model: opus-5-5
The prefix, AS and peer handlers skipped a timed write unless one
interval had passed since the last write ended. The next tick came a
little less than one interval after that, so every other tick was
skipped. Each tick now writes. A full batch's write restarts the timer,
so the next timed write comes one interval after that write began.
Comparing clock readings would not do: two ticks one interval apart can
read a hair under it. flushBatch no longer reports whether it wrote a
batch, since nothing reads that. A new test runs the loop on a fake
clock and fails on the old code.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #192.
Cause. The flush loop skipped a tick unless one interval had passed since the last write ended. The next tick came a little less than one interval after that. So the prefix handler wrote about every 2 seconds, and the AS and peer handlers about every 4.
Change.
flushBatchno longer reports whether it wrote a batch. Only the old check read that.TestFlushLoopWritesOnEveryTickrunsflushLoopin atesting/synctestbubble, whose clock is fake. It fails on the old code.Worth knowing.
time.Sleepin the test only moves the bubble's fake clock.Ticker.Resetdrops a tick already waiting in the channel, which the loop relies on; Go has guaranteed this since 1.23.Judgement call: the brief said to record the time a write starts and compare it at each tick. Two ticks one interval apart can reach the loop a hair less than one interval apart, so that comparison would still skip some ticks. Restarting the timer needs no comparison.
Unverified: that tick timing claim is reasoning, not measured.
Not changed:
TestPrefixHandlerWritesTheTableChangesEachSecondstill waits on the real one-second timer, as before. It tests that timer.Model: opus-5-5
PASS: this meets the definition of done of #192 and is ready to merge into
next.Model: opus-5-5