summaryrefslogtreecommitdiff
path: root/src/layout.zig
Commit message (Collapse)AuthorAge
* README: one thing a sketch keeps, in one file; what a crash loses; the capGabriel Schneider9 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The manual described a mapped state file, a sessions database beside it, a probe, private files for scripted runs and exits that compact past 64 MiB. Now, in The host: "The save" replaces "State file" (one thing, State, in one file, `<name>.xitdb`; the present restored and replayed at start; keyframes as pages and what they cost, measured; layout migration as before; an old `<name>.state` imported once and left as it was); "Where files go" lists `<name>.xitdb` and the files a sketch appends to, `--state x.state` and `x.xitdb` naming one save; "Sessions" says every run is one, `record` decides how much history is kept (a build that does not record keeps the present and the marks, the last minute of input at most while it runs, none after), a crash loses under a second and the next run starts from the last committed frame; a new paragraph, "The cap": 64 MiB, State half, history dropped oldest first and the file compacted to three quarters (about 170 ms in Debug), the present, marks and clips never dropped, a new mark refused with how to make room. The State row and "Data that grows" say 32 MiB; the appendFile paragraph names `<stem>.<name>` beside the save; scripts and exports save nothing; the Build API loses `probe`, `addProbe` and `probe_exe`; Known limits gains the hash pass's cost. layout.zig's note on what State may hold says where it is saved; micscope's README names its takes `micscope.take-<id>.f32`. Tests: zig build test, 168/168 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* The cap: a save is at most 64 MiB, State half of it, history dropped oldest ↵Gabriel Schneider9 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | first A save grew without bound. Now Sessions.max_save is 64 MiB and layout.max_state 32 MiB, so history always has room (the compile error says so: "State is N bytes, and may be 32 MiB, half of a save, so history has room: ..."). A commit that leaves the file past the cap trims it (Sessions.trim): one transaction drops history oldest first, a keyframe by removing its pages (its frame, batch and time stay, so keyframe numbers, keyBefore and marks by index still resolve) and a batch of frames by emptying its slot, until the keyframes' written pages and the batches left count three quarters of the cap; then the file is compacted into `<path>.new` and renamed over it, and the run goes on in the new file (compact now reopens). A dropped keyframe's pages may still be shared by a later one, so a round can free less than it counted: the next round lowers the count by the overshoot, four rounds at most. Never dropped: the present (the newest keyframe and the batches from its own on), the keyframe of the newest mark of each name, the keyframe of the newest clip of each name and every batch holding one of its frames. A session left with nothing loses its keyframes, batches and stretches; its summary stays. Asked for, what was dropped is error.HistoryDropped, which the console says in words ("That part of the history is gone: a save keeps 64 MiB, the newest."). Marks are pinned under the cap: a mark of a new name needs room for a whole State, history trimmed to make it; without, it is refused, error.SaveFull, the console saying how to make room: save over a mark's name (the older one then goes with history) or start another save. A mark over an existing name is always taken. (The spec's "room" rule, refusing only after a trim failed, let one mark take the file past the cap; room for a whole State keeps the cap hard, at the price of refusing early for a big State.) Builds that do not record (`history` false, from Info.record) use the same mechanism with the history limit zero: every commit holding a keyframe drops all it may (no compaction unless past the cap), and the exit compacts, so the disk holds at most the last minute of input while it runs and the present and the marks after. The exit compaction a recording build made past twice its contents plus 64 MiB is gone: the cap's compaction does that work. Measured (Debug, unit test): a trim of a 64 MiB file to 48 MiB takes 165-187 ms (two rounds of drop and compaction, the first ending 0.5% over); a no-history trim at a keyframe, 0-5 ms. ReleaseFast not measured. The console's `marks` reads each mark's keyframe fields, not its State: an older mark of a name may have gone with history (listed "dropped" when its session went whole). Docs: record means "keep history" in App.Options, sketch.Build and abi.Info. Tests: zig build test, 168/168 steps, 137/137 tests. New, in Sessions.zig: 100 keyframes of 1 MiB each with marks at the 5th and 20th: the file never past the cap, the oldest keyframes and frames HistoryDropped, both marks and the newest keyframe whole, the present's frames readable; without history, 20 keyframes and a mark: only the mark and the present stay, the file compacted at exit under three times the State and the present reopening whole; 2 MiB marks until one is refused (SaveFull, the file under the cap), then one over an old name taken and the file under the cap, every mark whole. 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
* Delete the Store; State is checked against the 64 MiB a save holdsGabriel Schneider9 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A sketch's data is State: flat bytes, what grows has its capacity in its type. The Store, a heap in a file mapped at 0x2000_0000_0000 with 64 GiB reserved, its power-of-two allocator, its root adopt and migration, and its test, are gone from memory.zig; so are Context.store and store_root, Info.store, Memory.store, the Store declaration's glue, Init.store, Frame.store and Console.store, the web host's store in wasm memory, the host's StoreFile wiring and `<state>.store` file, the `.store` suffix in moving an old state into .sketchbook/, the build's tests' `rm` of it, and layout.check's `pointers` flag (State is the one checked memory now). Its one real user, micscope, moved off it in the change before. Old `.state.store` files are not read, converted or deleted, and stay ignored by .gitignore. A sketch that still declares a Store gets no error for the declaration: nothing reads it, and a `*Store` parameter is a compile error (no argument of that type). layout.of(T, .state) refuses a State bigger than layout.max_state, 64 MiB, one constant: "State is N bytes, and a save holds at most 64 MiB: lower a capacity (an array, an sk.List), or keep what need not be saved in Session." The pointer-hash gap the spec found (a Store pointer's element type changing kept the old bytes) is gone with the only persisted memory that held pointers. README: no Store row, allocator row, migration paragraph, file bullet or known limits; draw and command lose their store parameter; State's row says 64 MiB at most; data that grows and is the user's work goes in a List in State or, bigger than a save, in files the sketch appends to. Tests: zig build test, 166/166 steps (the store's unit test gone; new: a 65-MiB State fails to compile with the message above, by expect_errors). micscope, spheres, noc's e2e and drat-meout's test unchanged and green. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* Build layout signatures without std.fmt at comptimeGabriel Schneider9 hours
| | | | | | | | Each comptimePrint costs about a millisecond of comptime, and a sketch's State, Session and Store reflection makes hundreds: drat-meout's library spent about 0.4 s of its sema on them. Numbers are spelled by a small decimal function instead; the signatures, leaf hashes and tag strings are byte for byte the same, so state files keep their meaning.
* sketchbook: a drawing layer on top, host fixes for replay and migrationGabriel Schneider5 days
|
* sketchbook: Zig 0.17, a Store on disk, requests, a scope (waveform, ↵Gabriel Schneider5 days
| | | | spectrum, spectrogram), audio codecs and fonts, web host
* Put the game first: lib/sketchbook, sketches/vecanimGabriel Schneider2026-09-25
The root is the game. The platform library moves to lib/sketchbook (with serve_web.py, which serves any sketch's web build, as a tool of it), and vecanim to sketches/vecanim, still its own package on the same library.