From 3350156db428656fa8e583d1971663e1c4a215b0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 18 Nov 2026 05:48:27 -0300 Subject: image: the image kind runs where its pane is shown (PA_PLAIN): its block is the file's size as it says, the same bytes in every process, and each process decodes the file on a draw of its own and keeps the RGBA beside the block (by its address) for its paint alone, so a client draws the picture itself and the session sends nothing for the pane (no Shadow, no decoded pixels in a job's answer on the tape); a plain kind's code is loaded in a client at its first pane, not at the join (Addon.need; a client with no picture or game maps no addon library); a client that joins late opens a plain kind's pane from its file, which the join's dump carries, read from the disk then (SlotRecord.file: paid only at a join), and one it cannot open shows the line; a client's join with a picture and a PDF open reads 10.70 MB -> 7.36 MB, its picture the session's pixel for pixel, its memory 269.1 -> 272.5 MB RSS (184.2 -> 187.6 PSS); with no client perf --only medium 2,279.68M -> 2,279.60M instructions:u, pdf-scroll-bench 18,392-18,399M -> 18,397-18,402M (its visual hashes the same), start to the first frame 53.6M (terminal) and 392-411M (window) as before; tui core-test 819/958 (139 skipped), shell-test 993/996, behaviour-test 273/273, --replay 20 seeds 0 failures, pane-test 180/181 (the picture's tag test steps the core, as no job's event does now), replicas pass, addon-test 1/1, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's), image-harness passes, test/daemon.py, --far, --games (keys stopped 0 and 0 of 453 and 452) and --window-clients pass; gui unit-test 1586/1590 (4 skipped; the perf check's BaselineBuildMismatch, the base's), the frame corpus 77/77 against mbase, pdf-harness CaptureColorMissing as on the base Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/dump.zig | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/dump.zig') diff --git a/src/dump.zig b/src/dump.zig index 971a4d26..c5e2953b 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -263,11 +263,15 @@ pub fn image(p: *Pardes, name: []const u8) ![]u8 { pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) ![]u8 { slim_terminals = true; defer slim_terminals = false; + join_files = true; + defer join_files = false; return dumpWith(p, deferred); } /// `dumpJoin`'s and `dumpExit`'s: a terminal dumps its size, not its emulator. pub var slim_terminals = false; +/// `dumpJoin`'s: a plain kind's pane carries its file (SlotRecord.file). +var join_files = false; fn dumpWith(p: *Pardes, deferred: ?*std.ArrayListUnmanaged(walk.Deferred)) ![]u8 { var d = try Session.init(p.gpa); @@ -782,6 +786,9 @@ const SlotRecord = struct { selection: []const u8 = "", /// A plain kind's block's hash (Kind.Slot.state). state: u64 = 0, + /// A client's join (`dumpJoin`): a plain kind's file, as the disk has + /// it now, which the client opens the pane from (plainHere). + file: ?[]const u8 = null, }; pub fn slotWrite(s: *const Kind.Slot, gpa: std.mem.Allocator, w: *std.Io.Writer) !void { @@ -795,6 +802,15 @@ pub fn slotWrite(s: *const Kind.Slot, gpa: std.mem.Allocator, w: *std.Io.Writer) owned = if (s.plain) |b| (if (b.len > 0) try s.gpa.dupe(u8, b) else null) else try slotRecord(@constCast(s)); r.record = owned; } + // Paid only at a client's join: the session keeps no file's bytes. + var file: ?[]u8 = null; + defer if (file) |f| s.gpa.free(f); + if (join_files and s.plain != null and s.ops != null) if (filesystem.localPath(s.path)) |path| { + const z = try s.gpa.dupeSentinel(u8, path, 0); + defer s.gpa.free(z); + file = filesystem.readHost(s.gpa, z, pardes.memory.limits.max_file_bytes) catch null; + r.file = file; + }; const bytes = try walk.save(SlotRecord, gpa, &r); defer gpa.free(bytes); try w.writeAll(bytes); @@ -830,6 +846,7 @@ pub fn slotRead(out: *Kind.Slot, gpa: std.mem.Allocator, bytes: []const u8) !voi out.values.set(r.values); out.selection = try gpa.dupe(u8, r.selection); if (r.record) |rec| out.record = try gpa.dupe(u8, rec); + if (r.file) |f| out.file = try gpa.dupe(u8, f); } pub fn slotFree(s: *Kind.Slot, gpa: std.mem.Allocator) void { @@ -883,7 +900,7 @@ pub fn plainHere(p: *Pardes, id: usize, old: *Kind.Slot, ops: *const Kind.Ops) ! s.path = try p.gpa.dupe(u8, old.path); s.selection = try p.gpa.dupe(u8, old.selection); const kept = .{ old.next_tick, old.views, old.focused, old.state }; - if (!Kind.reopen(p, id, s, null)) return error.KindRefused; + if (!Kind.reopen(p, id, s, old.file)) return error.KindRefused; // Its block the session's, byte for byte (its record), never through // the kind's load, which may tidy it. const block = s.plain orelse return error.KindRefused; -- cgit v1.3