cmux-tui: server-stats write_path counts the registry's WAL frame bytes (#32408, R-DURABILITY S-WS PR 1)
Part of #32408, R-DURABILITY stage S-WS PR 1 (design: handoff/rewrites/R-DURABILITY/S-WS-DESIGN.md, review SHIP in STATUS 9547). Diagnostics only: no behavior change.
What
server-stats with include: ["write_path"] now reports registry_wal_frame_bytes. That is the bytes of the WAL frames that the registry's commits appended (each frame is a 24-byte header plus one page). Two reads around one change give the bytes that change writes to the registry's disk. The S-WS red test reads this counter: one workspace create must write the same bytes at 50 and at 500 workspaces.
wal_durability: the WAL hook already counted each registry commit. Now it also takes SQLite's frame count after the commit and adds the frames that commit appended. A smaller count means the WAL restarted, so every frame is new.- The schema also lists
wal_commitsandwal_synced_commits. The daemon has sent both since 128427b45cff but the schema did not list them. All three fields are optional, because older daemons omit them. - spec/commands.md, docs/journal-operations.md, sdk-schema.json; SDK bindings regenerated with
bindings/codegen/generate.py --write.
Tests
- New:
wal_durability::tests::each_commit_counts_the_wal_frame_bytes_it_appended(one-row commits, a 256 KiB commit). - Linux fleet: clippy green (step dc390eef7667d419f77693c6);
wal_durabilitytests 5 of 5 pass, the new one included (step 5abfd373e1e47a1fee517fb2); fmt green on the same code. check-sdk-schema.py,check-spec-inventory.pyandgenerate.py --checkpass on the branch.
Observed / Not run
- Observed: the steps above. The counter used by the S-WS red test on macOS (aws-m4pro-7, step f80161b0b3fd5d0a791eafc6): 762 KB per create at 50 workspaces, 3798 KB at 500.
- Not run: macOS
cargo testof this crate (the Mac lane split). The counter does not depend on the platform.
Changelog
none
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Adds registry_wal_frame_bytes to server-stats write_path so tests can measure the bytes one change writes to the registry's disk. The WAL durability hook now records the WAL frame count after each commit and accumulates the appended frames times the frame size (a 24-byte header plus one page); two reads around a change give that change's bytes, and a smaller frame count means the WAL restarted, so all frames count as new.
The schema and api-compat surface also list wal_commits and wal_synced_commits, which the daemon has sent without schema entries. All three fields are optional so older daemons work unchanged. SDK bindings regenerated; spec and docs updated.
Tests
- New
each_commit_counts_the_wal_frame_bytes_it_appendedcovers one-row commits and a 256 KiB commit with overflow pages.
The counter is not exact in two cases, documented in the code, spec, and docs: the first commit after a WAL restart counts only the frames past the old WAL's count when it writes more frames than the old WAL held, and frames another connection appends to the same database count toward this connection's next commit.