Save a keepalive-only cursor move at most every 10 minutes
Each ntfy keepalive, every 45 seconds, moved the cursor and rewrote the subscription's state file with a synced write: about 1,900 a day per subscription while idle, which wears an SD card. A cursor that only keepalives or replayed repeats moved is now written at most every 10 minutes and at shutdown. A message printed, held or left out, a floor change, a digest, and the cursor's first move from 0 are still written within a second. A saved cursor that is behind costs only a longer replay after a crash, and the saved IDs drop what it sends again; a cursor still at 0 would mean a first start, which replays nothing. Tests check the lazy cadence and a crash that loses the later moves, the first move from 0 with an open event that has no time, and the write at shutdown. The soak now writes its state 325 times instead of 2,702. design.md records the decision. Its job-store entry now treats GORM on SQLite as the first choice and has the plan investigate SQLite in WAL mode, against bbolt and BadgerDB, before anything is built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb0c021044
commit
ee65e72c44
6 files changed
+162
-24
No files matched your search
@@ -76,7 +76,7 @@ func loadState(path string) (state, error) {
|
||||
}
|
||||
|
||||
// syncFile flushes a file, or a directory, to disk. It is a variable so
|
||||
// that tests, which write state files thousands of times, can skip the
|
||||
// that tests, which write state files hundreds of times, can skip the
|
||||
// flush; on a disk that is slow to sync, each one costs tens of
|
||||
// milliseconds.
|
||||
var syncFile = (*os.File).Sync
|
||||
|
||||
Reference in new issue
Block a user