diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 07:33:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 14:27:36 -0300 |
| commit | 5671a8275203334594b6f3b548e6a6012ef9fae6 (patch) | |
| tree | ee18ce296eea19620efdca231ee0de30b66c33f9 /core/fs.zig | |
| parent | 90ba0ef908dd65b322676f7a0f6edc5b7b976242 (diff) | |
| download | pardes-5671a8275203334594b6f3b548e6a6012ef9fae6.tar.gz pardes-5671a8275203334594b6f3b548e6a6012ef9fae6.zip | |
ninep: a client that joins a session with 9P work under way has the 9P state the session has: what a step reads that the requests made is the core's state like any other (P30, P35), so the walk sees it: fs leaves Pardes's and Pane's authority lists and the 9P server's own part says so in its types (fs.Namespace: the sockets, mounts, log, the request being served's flags and the rest; pane.State: the event and pty readers' queues and counts, winsize, unannounced; Open: the listener's held read and a stream's last answer; LogOpen whole), so the open records, the writes held to go in as one edit (fs.batch) and each pane's addr, limit, dot truncation, wrsel, joined, nomark, noscroll, lock, run, unmarked, tag truncation and chord are in every dump and in the digest; the digest is cheap by type: a pane's 9P state adds nothing for a pane no script has touched and its fields as one run of bytes for the rest (pane.State.digest), the namespace the opens in use and held writes by their length (Namespace.digest: a 9P body append hashed its whole batch, +0.14% on body-appends), so the frame and perf gate's 121 per-operation counts are within 0.1% of tree2 (largest client-key-down +0.054%; the plain walk of the same state cost client-key-down +0.73%); an open's union is named (Open.What) and digests what a step reads of it (its kind, a run, an event reader's flag, a pager's serial, a port's index), never the text its reader is answered with, which each process makes of its own state (walk.hash takes a tagged union's own digest as it takes a struct's); the opens are taken as far as fs.opens_len (an idle session's none; the scans that read records bound by it, openOf too, and an open lets go of what a rollback left in its record past the length); a session revived from a dump (Restore, an Upgrade, a start from one: dump.loadAndRevive; a closed pane brought back: loadPane) drops the opens and each pane's 9P state, as today, its connections gone (fs.Namespace.forget): a client's join loads alone and keeps them; not the join's dump alone: the tape's dump round trip at a replay's end wants the image to carry what the digest covers; pty.Run's answer cut at its length; the wire version 24, so the semantics word moves 64e89d6b25a84796 -> 18636a639ac075de (it did not move with the walk alone: a base client would have digested other fields than its session; test/daemon.py's WIRE with it, and its upgrade case takes a client of the other side's protocol saying `run the same pardes at both ends`, as its third terminal already did); the eleven tests of the change before pass; a join's dump (the probe, Debug): idle 63258 -> 64612 bytes, 50 opens held 63270 -> 66744; the image idle 233426 -> 237001, 50 opens 233738 -> 295089; tui core-test 867/1022 (155 skipped), shell-test 1062/1065, behaviour-test 275/275 and --replay 275/275, replicas --clients 5 diverged 0/0/0, unequal 0, unlisted stops 0, corpus 22 of 22, no leak (load 30-40, before the digests were made cheap; the whole gate on the change after)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/fs.zig')
| -rw-r--r-- | core/fs.zig | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/core/fs.zig b/core/fs.zig index 6e5829e1..dcc33cd6 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -841,6 +841,30 @@ pub const EditHold = struct { }; pub const Namespace = struct { + /// What a step reads that 9P requests made (every request an input + /// each replica replays) is the core's like any state: the open + /// records and the writes held to go in as one edit, digested and dumped (a client's join takes them from + /// the dump; a session revived from one drops the opens with the + /// connections that held them: dump.zig `loadAndRevive`). The rest is + /// the server's (core/walk.zig): its sockets and the mounts (dumped + /// on their own), the log and what a reader or a listener is answered + /// with, and the request being served's own flags, set and read in + /// its step. ponytail: `edit_hold`, set by the session's listener + /// between steps and read by the retried write's step, is no + /// replica's (reports/pardes-faults-4.md). + pub const replica = .{ + .authority = .{ + "socket_path", "tcp_address", "mounts", "node_name", "os_paths", "out", + "listeners", "origin", "no_prompt", "session_write", "unlogged", "capturing", + "serving", "refused", "failure", "failure_len", "no_pane_slot", "no_pane_slot_len", + "said", "said_len", "said_at", "late_failure", "late_failure_len", + "lsp_answer_at", "edit_started", "edit_hold", "edit_said", "lsp_result", "write_room", + "write_waits", "log_full_hash", "pages", "closed_lines", "ran_at", "refilled", + "failures", "ename", "news", "hanging_up", "log", "plumb_held", + "results", "results_len", "started", "header_rewrite", "header_trunc_pending", "header_held", + }, + .len = .{.{ "opens", "opens_len" }}, + }; socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, mounts: std.ArrayList(Mount) = .empty, @@ -848,6 +872,9 @@ pub const Namespace = struct { os_paths: std.ArrayList(OsPath) = .empty, /// What each open holds between its open and its release. opens: [tree.open_slots]tree.Open = @splat(.{}), + /// The records past it are free: a digest and a dump take the opens + /// this far (an idle session's none). + opens_len: u8 = 0, out: std.ArrayList(u8) = .empty, listeners: u16 = 0, origin: u8 = 'K', @@ -995,6 +1022,29 @@ pub const Namespace = struct { st.out.deinit(gpa); } + /// Its digest (core/walk.zig): the opens in use, and writes held by + /// their length (their bytes are the same writes on every side; a + /// stream of 8 KB appends hashed whole cost each its length again; + /// none held, the rest of `batch` is nothing a step reads). Nothing at + /// all for a session no script holds anything of. + pub fn digest(st: *const Namespace, h: *pardes.walk.Hasher) void { + comptime if (pardes.walk.fieldNames(Namespace).len != 3) @compileError("Namespace.digest: hash every field the walk does not leave out"); + for (st.opens[0..st.opens_len]) |*o| pardes.walk.hash(tree.Open, o, h); + const b = &st.batch; + if (b.bytes.items.len == 0) return; + const words = [_]u64{ b.serial, b.node, b.handle, b.at, b.bytes.items.len, b.last_ns }; + h.update(std.mem.asBytes(&words)); + } + + /// What the requests of connections gone made, let go: a session + /// revived from a dump has none of the connections that held its opens. + pub fn forget(st: *Namespace, gpa: std.mem.Allocator) void { + for (&st.opens) |*o| o.deinit(gpa); + st.opens_len = 0; + st.batch.bytes.deinit(gpa); + st.batch = .{}; + } + pub fn mount(st: *Namespace, gpa: std.mem.Allocator, name: []const u8, dial: []const u8) !void { if (!validMountName(name)) return error.BadMountName; try ninep_io.Client.validateDial(dial); |
