| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The plain buffer of part 1 gives way to pardes's text pane as a library
(`pardes-editor`, src/lib_editor.zig there): `Editor(.{ .text = 4096,
.undo = 16 KiB, .registers = 1024, .selections = 64 })`, a value of plain
data, 39,264 bytes of a State of 43,480. The package takes pardes by path
(`../../../02-pardes-code`, the checkout beside sketchbook's) with
`.editor = true` and its smallest tree-sitter set; sketchbook is spelled
`../../../sketchbook` as pardes spells it, since a package is told by its
path's spelling and sketchbook's build.zig cannot be two modules.
`update` turns events into keys: printables from `text` events only,
specials (Escape, Return, Backspace, Tab, arrows, Home, End, pages,
Delete) and ctrl or alt chords (helix's `A-I` an upper-case letter) from
`key_down`, a chord's letter dropped if it also comes as text. Each call
into the editor thaws the value into a static 128 KiB buffer reset for
the call (`update` may not allocate from the host; a key at 4 KiB of text
took 29 KiB of it). The text is compiled when the editor's `revision`
moves.
Measured (a scratch bench through `update`, the survey's program, 646
bytes, a key typed into its middle, 400 times): a typed key, edit and
compile, 59.5 us best and 78.8 mean in Debug, 7.4 and 7.8 in
ReleaseFast; a motion 6.4 and 0.3. The package's cold `zig build lib`
went from 3.1 s to 6.6 s, its first build under `--watch -fincremental`
from 4.0 to 5.9 s, and an edit of main.zig rebuilt under it from
0.062-0.067 s to 0.067-0.092 s.
Test: test/live.script types through helix now (`i`, the text, Escape,
`gl`, `h`, `rx` for the edit, `l` `d` to break the line, `u` to mend it)
and still replays to equal text, tapes and screenshots, its seeks moved
to the marks' new times. zig build test: 81 of 81 steps, 6 of 6 tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
|
|
Demo 1's route: a program becomes a flat tape of at most 128 instructions
(src/Lang.zig: the ops, the instruction, the tape and the two uniform
blocks that carry it; build.zig writes Lang.Op out as ops.glsl, so the op
numbers have one definition), and ONE interpreter, shaders/vm.glsl, runs it
per pixel (picture.frag) and per sample (synth.comp, crossing from the
tape it replaces over the first `fade` samples). Instruction i writes
register i; the tape is pushed as uniforms.
The probe measures it before anything else is built: `zig build probe`
plays made-up tapes (every instruction reaching the last, a noise in ten)
under --profile-gpu. RTX 3050 (driver 620.70.06), Debug host, means of 601
frames, three runs agreeing within 0.07 ms:
picture, empty tape 720p 0.14-0.23 1080p 0.19-0.28 (a pass's cost)
picture, 60 720p 1.38-1.45 1080p 2.89-2.96
picture, 128 720p 2.71-2.81 1080p 5.86-5.95
picture, 128 at 640x360 0.85-0.94
The budget, under 2 ms at 1280x720: 60 instructions meet it, 128 do not.
The cheap fixes, on 128 at 720p: the tape in a storage buffer 2.97-3.03
(worse); the registers as an array of 16 (kept in registers, indexing
turned into selects) 5.82-5.93 (twice as slow); the 128-array with only
16 slots used 2.11-2.34 (cache footprint: a register allocator would buy
about a sixth); half resolution 0.85-0.94. So the sketch will draw a
tape longer than 64 instructions at half resolution, scaled up. The
variants are kept outside the tree. The synth's numbers taken here were
of a kernel that wrote nothing (its uniform block was past SDL's 4 KiB):
the sound's change measures it again.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|