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/Jump.zig') 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/Jump.zig') 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 0b612d26ed32ee765f450c643f77fe4a749a2847 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 16:16:51 -0300 Subject: jump list: the dedupe stores an entry and then compares it where it is stored, `walk.eql(Loc, &list[w - 1], &list[w])`, where it compared `&kept`: the pointer to `kept` (56 bytes) made it a stack temporary for every entry of every step (`walk.eql` compares a place's bytes cut to their length by a call, `mem.eqlBytes`, given that pointer), about 8 instructions an entry: body-appends +12.6 k an op over tree6 (+0.0874% on longline), where `std.meta.eql` inlined kept it in registers; THE RUN THAT SETTLED IT (pardes-release-soak-2 item 1, exp1): pardes-perf of this tree with `walk.eql` (A) and with the compare put back to `std.meta.eql` (B): the jump list after every body-appends rep is the same entry for entry in both (k+2 entries after rep k, no two neighbours equal as the digest sees them: the dedupe decides nothing in that cell), B +54.0 k an op (its `std.meta.eql` not inlined: a call and two stack copies an entry) where tree6 is 0 and the installed tree -5.6 k: one source line compiled three ways; the cost was the compare's code, not a deduplication; with this, perfops against tree6: 120 of 121 within 0.1%, body-appends -0.0307% on longline and -0.021% on small, medium, large, the one over the base's own `open` cell (+8.8 k an op, another agent's: +0.167% on small) (load 2.9); Debug core-test filtered on the jump tests: the two Jump.zig tests pass Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Jump.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/Jump.zig') diff --git a/core/Jump.zig b/core/Jump.zig index d85ff75a..ccdb8fdc 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -205,11 +205,13 @@ 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; 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)) { + // Compared where it is stored (w <= i: read already): a pointer + // to `kept` put it on the stack for every entry of every step. + v.jumps.list[w] = kept; + if (w > 0 and pardes.walk.eql(Loc, &v.jumps.list[w - 1], &v.jumps.list[w])) { if (i == v.jumps.cur) cur = w - 1; continue; } - v.jumps.list[w] = kept; w += 1; } v.jumps.n = w; -- cgit v1.3