diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 19:50:04 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 21:53:39 -0300 |
| commit | 1ae6addf4590d3b9c1070f6546c29e807d272491 (patch) | |
| tree | 0c9a618753dcb214c2c614a13f62d2ea28b3c895 /core/rollback.zig | |
| parent | 391c1383011f4fb84743f824c6cc29e68cc4beb7 (diff) | |
| download | pardes-1ae6addf4590d3b9c1070f6546c29e807d272491.tar.gz pardes-1ae6addf4590d3b9c1070f6546c29e807d272491.zip | |
rollback: the copy walks a type by its fields when it says what they are (`replica`), whatever digest of its own it has: it skipped every type with one as if it were a terminal, so since faults-4 the 9P state (fs.Namespace, a pane's ninep State) was saved only as the bytes of its records, never the buffers they own, and a unit kept over a copy that wrote one in place came back other than it was (a script's exec held "Ta", the next write ran `Tab 8` and moved "Un" to the front of the same buffer, and the rollback's replay ran `Unb 8`: the client's digest other than the session's); now only a type with a digest and no `replica` (Term.State, the authority's emulator; locations.Row, made again and never written) is left out (`unwalked`); the test, that exec write over a copy taken ahead and a rollback by another's key, differed on the base (digest 12509739004356058903 against 4039275215734315918) and passes; the tree gated whole (load 1-8): tui core-test 875/1033 (158 skipped), shell-test 1075/1078, term-test 17/17, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test 0 of 145 failed; both soaks diverged 0, unequal 0, unlisted 0, quiet checks 597/0 673/0 779/0 and 693/0 586/0 829/0, the corpus 22 of 22, no leak; daemon.py --clients 39 of 40 alone and 20 of 20 pinned, plain 5 of 5, --far, --far-find, --relink, --launch, --pair, --restore, --games (addon-test 5/5), --window-clients (its PDF case skipped: no pdf.so in a tui prefix), --gui pass; the cross-builds (macos, macos arm, freebsd) build; the frame and perf gate against tree2: 77/77 frames, perfab +0.043%, 121 per-operation counts within 0.1% (largest client-key-down on medium +0.0749%), gui unit-test 1671/1675 with no failure the base has not
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/rollback.zig')
| -rw-r--r-- | core/rollback.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/rollback.zig b/core/rollback.zig index c7d0a4e8..a55d3c87 100644 --- a/core/rollback.zig +++ b/core/rollback.zig @@ -404,9 +404,7 @@ pub const Copy = struct { }, .@"struct" => |s| { if (comptime walk.machinery(T)) return; - // A terminal: the authority's (its emulator is never written - // by a speculation: terminal.zig's guards). - if (comptime @hasDecl(T, "digest") and @TypeOf(T.digest) == fn (*const T, *walk.Hasher) void) return; + if (comptime unwalked(T)) return; if (s.layout == .@"packed") return; // std's lists (a safe build's have a third field, a lock). if (comptime walk.isList(T)) { @@ -467,7 +465,7 @@ pub const Copy = struct { if (comptime walk.machinery(P)) return; const addr = @intFromPtr(ptr); if (try c.reached(P, addr)) return; - if (comptime @hasDecl(P, "digest") and @TypeOf(P.digest) == fn (*const P, *walk.Hasher) void) return; + if (comptime unwalked(P)) return; if (c.epoch.?.owns(addr) != null) { _ = try c.reached(void, addr); try c.fields(P, ptr); @@ -513,6 +511,16 @@ pub const Copy = struct { } }; +/// A type that hashes itself and says nothing of its fields (`replica`): +/// a terminal, the authority's (its emulator is never written by a +/// speculation: terminal.zig's guards), or a location row, made again and +/// never written. One that says its fields' kinds is walked by them, +/// whatever digest it has (the 9P state, fs.Namespace and a pane's: a +/// replayed request writes its buffers in place). +fn unwalked(comptime T: type) bool { + return @hasDecl(T, "digest") and @TypeOf(T.digest) == fn (*const T, *walk.Hasher) void and !@hasDecl(T, "replica"); +} + fn annotatedStruct(comptime T: type) bool { return @typeInfo(T) == .@"struct" and @hasDecl(T, "replica"); } |
