From 37cc3104fe589ec7cd2a8a5dd398f0f89f412837 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:25:44 -0300 Subject: jump: the test of two jump entries the same but for the bytes past their place's length: both release soaks of the base parted a client at seed 0 and 30 ms ("client 5 parted on unit 0/1407", "client 3 parted on unit 0/1749" then "on unit 1/106"), the witness naming `views[3].jumps` and `views[0].jumps`; trackJump (core/Jump.zig:207) drops the second of two entries in a row that std.meta.eql calls the same, and std.meta.eql compares a Loc's `place` (a Kind.Buf(32)) byte for byte, past its length: a text pane's entry has `.place = .{}`, its bytes undefined, 0xAA on every Debug process and on a release build whatever that process's stack (or a client's load) left there: the session keeps two entries the client makes one (or the other way), and the client parts; the test puts two such entries round a gone one, their place bytes 0x11 and 0x22, and fails in Debug: "expected 3, found 4" (logs/t6-jump-test.log) (PARDES_REPLICA_TRACE's "digest 36 differs in next_serial" of the round before was the soak's own divergence put on its second client, test_diverge = 40, counted "rejoined", not this) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Jump.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'core') diff --git a/core/Jump.zig b/core/Jump.zig index b68da32d..66d0ba51 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -367,6 +367,28 @@ test "the jump list never holds two entries in a row the same, when the one betw try std.testing.expectEqual(@as(u32, 150), p.view().jumps.list[1].line); } +test "two entries the same but for the bytes past their place's length are one entry, as the digest sees them, on every build" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 40 }); + defer p.deinit(); + const pane = try p.setTestFile(std.mem.asBytes(&@as([200][2]u8, @splat("a\n".*)))); + // A text's entry has no place: `.place = .{}`, its bytes undefined, + // 0xAA on every Debug process and each release process's own (the + // stack's, a load's): one entry on every side or a client parts. + var a: Loc = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; + var b = a; + @memset(&a.place.bytes, 0x11); + @memset(&b.place.bytes, 0x22); + p.view().jumps.list[0] = a; + p.view().jumps.list[1] = .{ .pane = 5, .serial = 999, .line = 1, .col = 1 }; + p.view().jumps.list[2] = b; + p.view().jumps.list[3] = .{ .pane = 0, .serial = pane.serial, .line = 150, .col = 1 }; + p.view().jumps.n = 4; + p.view().jumps.cur = 3; + pane.body.cur_row = 80; + trackJump(p); + try std.testing.expectEqual(@as(usize, 3), p.view().jumps.n); +} + test "jump history skips an entry whose pane slot or serial is gone, leaving the selection" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); -- cgit v1.3 From 339ebde8df16f79197c2fd469eedba5edec750c4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:33:05 -0300 Subject: jump, walk: two jump entries in a row are one when the digest sees them the same (`walk.eql`: the digest of each, so what the walk leaves out, a Buf's bytes past its length, a cache, decides nothing), not by std.meta.eql's every byte: core/Jump.zig:207 took the dedupe on a text entry's `place` bytes, undefined (`.place = .{}`), the same 0xAA on every Debug process and each process's own on a release build, so a session and its client kept different jump lists and the client parted (both release soaks of the base, the witness naming `views[3].jumps`, `views[0].jumps`); the test of the change before passes (Debug) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Jump.zig | 7 ++++--- core/walk.zig | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/Jump.zig b/core/Jump.zig index 66d0ba51..d85ff75a 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -203,8 +203,9 @@ pub fn trackJump(p: *Pardes) void { }; } // Two in a row the same (a closed one reopened beside its own, - // or the entry between them gone): one entry, one step. - if (w > 0 and std.meta.eql(v.jumps.list[w - 1], kept)) { + // or the entry between them gone): one entry, one step; the same + // as the digest sees them (a text's `place` is bytes undefined). + if (w > 0 and pardes.walk.eql(Loc, &v.jumps.list[w - 1], &kept)) { if (i == v.jumps.cur) cur = w - 1; continue; } @@ -361,7 +362,7 @@ test "the jump list never holds two entries in a row the same, when the one betw p.view().jumps.cur = 3; pane.body.cur_row = 80; // where you are now: far from both trackJump(p); - for (1..p.view().jumps.n) |i| try std.testing.expect(!std.meta.eql(p.view().jumps.list[i - 1], p.view().jumps.list[i])); + for (1..p.view().jumps.n) |i| try std.testing.expect(!pardes.walk.eql(Loc, &p.view().jumps.list[i - 1], &p.view().jumps.list[i])); try std.testing.expectEqual(@as(usize, 3), p.view().jumps.n); try std.testing.expectEqual(@as(u32, 1), p.view().jumps.list[0].line); try std.testing.expectEqual(@as(u32, 150), p.view().jumps.list[1].line); diff --git a/core/walk.zig b/core/walk.zig index d870052d..898a7cf7 100644 --- a/core/walk.zig +++ b/core/walk.zig @@ -89,6 +89,15 @@ pub fn digest(comptime T: type, v: *const T) u64 { return h.final(); } +/// Equal as the digest sees them: what the walk leaves out (a Buf's bytes +/// past its length, a cache) is not compared. std.meta.eql compares every +/// byte of an array, and those bytes are undefined: 0xAA on every Debug +/// process, each release process's own garbage; a decision of the core +/// taken on them agrees between a session and its clients in Debug alone. +pub fn eql(comptime T: type, a: *const T, b: *const T) bool { + return digest(T, a) == digest(T, b); +} + /// A digest of each field `hash` would walk, in order (what a divergence /// is narrowed down by); `names` are theirs. pub fn fieldDigests(comptime T: type, v: *const T, out: []u64) []u64 { -- cgit v1.3 From de0b9a53ad18555708121b31a3dc813cbda8fa0e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 12:13:42 -0300 Subject: walk: `eql` by the digest's own rules, field by field (a field `replica` leaves out skipped, a `len`-cut array to its length, flat arrays and slices by std.mem.eql, a type that walks itself by its digest), where it took the digest of each: the jump dedupe calls it for every pair on every step, and two Wyhash walks a pair put 32 of pardes-perf's 121 per-operation counts over 0.1% (every key, wheel, page and edit op about +26k instructions, body-appends +1.74M); with this, 120 of 121 within 0.1%, body-appends on longline +0.1001% and on small, medium, large +0.067% (the same +14.5k instructions an op: the dedupe deciding as the digest does where the base's release garbage decided otherwise; every body-appends setup cheaper), everything else within 0.02% (against tree6, load 4.2-4.6); core-test 926/1090 (164 skipped), shell-test 1132/1135 (3 skipped) in Debug (loads 5.0-10.2) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/walk.zig | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/walk.zig b/core/walk.zig index 898a7cf7..593532f8 100644 --- a/core/walk.zig +++ b/core/walk.zig @@ -89,13 +89,43 @@ pub fn digest(comptime T: type, v: *const T) u64 { return h.final(); } -/// Equal as the digest sees them: what the walk leaves out (a Buf's bytes -/// past its length, a cache) is not compared. std.meta.eql compares every -/// byte of an array, and those bytes are undefined: 0xAA on every Debug -/// process, each release process's own garbage; a decision of the core -/// taken on them agrees between a session and its clients in Debug alone. +/// Equal as the digest sees them, by the digest's rules: what the walk +/// leaves out (a field `replica` names, a Buf's bytes past its length) is +/// not compared; a type that walks itself, by its digest. std.meta.eql +/// compares every byte of an array, and those bytes are undefined: 0xAA on +/// every Debug process, each release process's own garbage; a decision of +/// the core taken on them agrees between a session and its clients in +/// Debug alone. pub fn eql(comptime T: type, a: *const T, b: *const T) bool { - return digest(T, a) == digest(T, b); + switch (@typeInfo(T)) { + .void => return true, + .bool, .int, .@"enum" => return a.* == b.*, + .optional => |o| return if (a.*) |*x| (if (b.*) |*y| eql(o.child, x, y) else false) else b.* == null, + .array => |arr| { + if (comptime flatHash(arr.child)) return std.mem.eql(arr.child, a, b); + for (a, b) |*x, *y| if (!eql(arr.child, x, y)) return false; + return true; + }, + .@"struct" => |s| { + if (comptime machinery(T)) return true; + if (comptime s.layout == .@"packed" or @hasDecl(T, "digest") or isList(T) or isAtomic(T) or isBitset(T) or @hasField(T, "any_future")) return digest(T, a) == digest(T, b); + inline for (s.field_names, s.field_types, s.field_attrs) |name, F, attr| { + if (attr.@"comptime" or comptime excluded(T, name)) continue; + if (comptime lengthOf(T, name)) |len| { + const x = @field(a, name)[0..lengthIn(a, len)]; + const y = @field(b, name)[0..lengthIn(b, len)]; + if (comptime flatHash(Element(F))) { + if (!std.mem.eql(Element(F), x, y)) return false; + } else { + if (x.len != y.len) return false; + for (x, y) |*p, *q| if (!eql(Element(F), p, q)) return false; + } + } else if (!eql(F, &@field(a, name), &@field(b, name))) return false; + } + return true; + }, + else => return digest(T, a) == digest(T, b), + } } /// A digest of each field `hash` would walk, in order (what a divergence -- cgit v1.3