diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 01:27:03 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 8bf10e316178755b8710e27c807dbf9b6a1d37a8 (patch) | |
| tree | 99edaa7916fe0c2e5f7f90bd600c32f414fbc47d /src/gpu/Cells.zig | |
| parent | 1ce323f2f21b94f9c4fc4e7a6986612cf30cf183 (diff) | |
| download | sketchbook-8bf10e316178755b8710e27c807dbf9b6a1d37a8.tar.gz sketchbook-8bf10e316178755b8710e27c807dbf9b6a1d37a8.zip | |
The cap: a save is at most 64 MiB, State half of it, history dropped oldest 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
Diffstat (limited to 'src/gpu/Cells.zig')
0 files changed, 0 insertions, 0 deletions
