Notes: save at least every 5 s while someone types nonstop (#297) #408

Closed
kayg wants to merge 0 commits from issue/297-save-max-delay into dev
Owner

Closes #297.

What
A note's room saved its file only after 750 ms without changes, so someone typing without a pause kept postponing the write: history had every change, but the .md that outside tools, sync and backups see could lag for minutes. Now a save also happens at the latest 5 s after the first unsaved change (Options::flush_max, next to flush_quiet). Saves stay atomic; a failed save keeps its backoff (the 5 s cap only applies while saves succeed). ADR 0021 and CONTEXT.md say so.

Test: nonstop_typing_still_saves: a keystroke every 50 ms for 1.5 s with a 400 ms quiet delay and a 300 ms cap; the file must be written while typing goes on, and everything must be saved at the end.

Cost (the #44 harness on the perf VM, one base, dev a305ee2 vs dev + this + the #298 PRs, 10k and 100k notes, 3 warm runs + 1 cold each; full table on #298): every gated budget holds. load.typing (one person typing 5 chars/s for a minute, which now saves every 5 s instead of once at the end): CPU 0.8 → 0.6 % at 100k, 0.9 → 0.57 % at 10k (budget 2 %); wake-ups 37 → 56 /s (not budgeted; the extra saves). sync.round_trip p95 1.29 → 1.44 ms at 100k (budget 10), storm.save_ack p95 40 → 43 ms (budget 150). A save (with its change journal entry) costs about 10 ms of CPU, the same at 10k and 100k notes (measured separately, in-process, at the 10 ms resolution of the CPU clock), so the extra saves don't get dearer as the Home grows.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Closes #297. **What** A note's room saved its file only after 750 ms without changes, so someone typing without a pause kept postponing the write: history had every change, but the `.md` that outside tools, sync and backups see could lag for minutes. Now a save also happens at the latest 5 s after the first unsaved change (`Options::flush_max`, next to `flush_quiet`). Saves stay atomic; a failed save keeps its backoff (the 5 s cap only applies while saves succeed). ADR 0021 and CONTEXT.md say so. **Test**: `nonstop_typing_still_saves`: a keystroke every 50 ms for 1.5 s with a 400 ms quiet delay and a 300 ms cap; the file must be written while typing goes on, and everything must be saved at the end. **Cost** (the #44 harness on the perf VM, one base, dev a305ee2 vs dev + this + the #298 PRs, 10k and 100k notes, 3 warm runs + 1 cold each; full table on #298): every gated budget holds. `load.typing` (one person typing 5 chars/s for a minute, which now saves every 5 s instead of once at the end): CPU 0.8 → 0.6 % at 100k, 0.9 → 0.57 % at 10k (budget 2 %); wake-ups 37 → 56 /s (not budgeted; the extra saves). `sync.round_trip` p95 1.29 → 1.44 ms at 100k (budget 10), `storm.save_ack` p95 40 → 43 ms (budget 150). A save (with its change journal entry) costs about 10 ms of CPU, the same at 10k and 100k notes (measured separately, in-process, at the 10 ms resolution of the CPU clock), so the extra saves don't get dearer as the Home grows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Notes: save at least every 5 s while someone types nonstop (#297)
Some checks failed
CI / server (pull_request) Successful in 31s
CI / rust (pull_request) Successful in 2m34s
CI / web (pull_request) Failing after 44m7s
95995a8005
A room saved its file only after 750 ms of quiet, so someone typing
without a pause kept pushing the file write back, and the .md that
outside tools, sync and backups see could lag for minutes. Now the save
also happens 5 s after the first unsaved change at the latest
(`Options::flush_max`). Failed saves keep their backoff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Landed in dev via train k (#441).

Landed in dev via train k (#441).
kayg closed this pull request 2026-10-15 14:34:29 +00:00
Some checks failed
CI / server (pull_request) Successful in 31s
CI / rust (pull_request) Successful in 2m34s
CI / web (pull_request) Failing after 44m7s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!408
No description provided.