summaryrefslogtreecommitdiff
path: root/test/render.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 01:13:36 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit1ce323f2f21b94f9c4fc4e7a6986612cf30cf183 (patch)
tree87342ff0ca8bf9e08ba8060ffddd6a64bfca7adf /test/render.zig
parent62cce7f3d96aa054b2bc2055dce86dd8e4205256 (diff)
downloadsketchbook-1ce323f2f21b94f9c4fc4e7a6986612cf30cf183.tar.gz
sketchbook-1ce323f2f21b94f9c4fc4e7a6986612cf30cf183.zip
The present lives in the save: one file a sketch, the state file gone
A sketch kept its live State in a mapped state file and its history in a sessions database beside it. Now the database is the save, the one file: the present is its newest keyframe and the frames logged after it, and a run starts there (Sessions.present: the newest session with a keyframe, its last keyframe loaded and the frames after it read). Host restores it (migrating across a layout change, as a seek does) and replays the frames through `update`, unlogged, `started` as it was fed (true only from a session's first frame); played by another build, they are not replayed, and the run says how many frames that was. The run's first keyframe then starts from the present's pages, so a session costs what changed since the last one. --fresh still starts from defaults, the save untouched. State is process memory (memory.State: one page-aligned allocation, its layout, and its layout header for the stretches); a reload's adopt allocates the new layout's defaults and migrates the old bytes into it, and returns null when unchanged. Gone: StateFile, its slots, used bits, resize, dropSnapshots and the adopt that rewrote a file's header; the sketch-facing `Host.state` keeps `layout`; Timeline restores into `state.live()`. `adopt` no longer runs `init`: openPresent does when there is no present. Every run saves: the database is opened in a file for every run but a scripted one from fresh state (memory, nothing on disk) and an export (none). So release builds keep their State as before, and marks and clips work there; `.record` keeps or trims history (next change). The save is `<stem>.xitdb`, `<stem>` being --state without `.xitdb` or `.state`: `--state x.state` and `--state x.xitdb` name the same save. Defaults: `.sketchbook/<name>.xitdb` under zig build run, and `$XDG_DATA_HOME/<name>/<name>.xitdb`. A sketch's appended files are `<stem>.<name>` (micscope's takes: `.sketchbook/micscope.take-3.f32`, where Phase 1 wrote `micscope.state.take-3.f32`; that naming never left this workspace, so nothing of the user's is renamed). A scripted run from fresh state or an export appends to `<stem>.<pid>.<name>` and removes those at exit; the private state file and the exit's moving of files by prefix are gone from root.zig. Old state files: in a new save, `<stem>.state` (one slot or eight, any of the three formats) is imported once: slot 0 becomes the present (in today's layout), slots 1-7 marks "1".."7" (migrated to it, as before); the file is read through a read-only mapping and left exactly as it was. It is never read again: the save then has a session. A file that is no state file is said and left. .sketchbook/'s move of an older build's `<stem>.state` from beside it stays, now by stem. sketchbook-probe is deleted (86 lines, its build step, Sketchbook's probe_exe, App.addProbe): it mapped the state file. Reading the save instead would show State as of the newest keyframe, up to a minute old, never the frames after it, which only `update` can turn into State; and it would need a read-only open the host has no other use for. The planned 9P state/ tree reads live State from the process. A kill -9 now loses what the session log always lost: the frames not yet committed (under a second: in test-kill 15 of 255 frames, the next run starting from frame 240's State), keyframes and marks queued since the last commit (a mark commits at once, synced), the session's end time and an open clip's end. The mapped file lost nothing to a kill. A power loss reopens at the last commit the disk holds whole (`mend`); commits are fsynced only for marks and at exit, so what the OS had not written back is lost (not measured); the mapped file, never synced, could tear page by page. Measured: drat-meout's State, 20 extra jump keyframes in a 2,400-frame script, 100,708 B more than the same frames without them: about 5 KB a keyframe, where the whole State (17.7-20 KiB) was written each time. Tests: zig build test, 168/168 steps. test-kill runs for a recording and a non-recording build, and the second run checks `updates` is 240 (replayed), not only the session's frame count. test-paths: the XDG directory holds `replay.xitdb` alone; .sketchbook/ holds `.gitignore` and `replay.xitdb`; the next run's State is the one the last left; an older `old.state` beside .sketchbook/ is moved in once, never over a file, and left as it was when it is no state file. test-same: a run from fresh state leaves no file at all. Rewritten: memory.zig's state file tests as State's (migrate, unchanged) and OldState's (refused untouched; drat-meout's v1 fixture imports every value, the file unchanged), Host's snapshot import as importOld (State live, two marks, the file byte for byte as it was), Host's setup test without a file, the timeline test on a State. micscope 67/67, 10/10; spheres 75/75, 3/3; noc e2e 292/292; the drat-meout copy 87/87, 30/30. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/render.zig')
0 files changed, 0 insertions, 0 deletions