summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 16:38:10 -0300
committerGabriel Schneider <[email protected]>2026-11-18 17:13:49 -0300
commitf7fc58ee8ae9a88b09ee1c235b9986df8b1ef844 (patch)
tree0dde3920324473b0e827ae61d87c44c4ba77030b /test
parent558051ca5525a4dade47ab6ef7794eefd848f7b2 (diff)
downloadpardes-f7fc58ee8ae9a88b09ee1c235b9986df8b1ef844.tar.gz
pardes-f7fc58ee8ae9a88b09ee1c235b9986df8b1ef844.zip
replica: a client compares its core's digest with the session's only where one is due, not at every confirmed input and every unit replayed (the edit row's +40%, a full walk of the core each time): once in check_every (32) confirmed units, on a unit that carries one with nothing applied on top (the fast path's catch-up, a replay, a rollback's), and once quiet 300 ms after a change (Link.quietCheck, now always, not only for PARDES_REPLICA_CHECK: another digest is a divergence, and it joins again; PARDES_TEST_DIVERGE is found so); a unit replayed by a rollback (since) compares none; a unit with no digest leaves the last one unknown (after a unit with a set record it was kept, stale, for the moved-nothing comparison); the authority in process records its digest at a unit's end as the session does; the session still records one a unit (a session's unit with none where its clock moved exposed a structural divergence after a kind is distrusted: daemon.py --games, a second rejoin, 'the tape's answer to addon is short'; not root-caused); the soak's mix without the PDF (round 5's open fault); replicas five clients diverged 0, unequal 0, the put-off client caught by a quiet check or a due one
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/replicas.zig40
1 files changed, 15 insertions, 25 deletions
diff --git a/test/replicas.zig b/test/replicas.zig
index 29923379..bd759b03 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -48,8 +48,6 @@ const gpa = std.heap.c_allocator;
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
var trace = false;
const frame_us = 16_667;
-/// The PDF its clients look at (`--pdf`), when the build has the addon.
-var pdf_path: ?[]const u8 = null;
/// A frontend's workers for pictures' draws (Kind.drawer, tui.zig
/// `Shell.draw`): each draw asked of any core here runs `draw_us` later,
@@ -190,6 +188,8 @@ const Totals = struct {
mispredicted: u64 = 0,
foreign: u64 = 0,
rebases: u64 = 0,
+ /// A client's digest compared with the session's (a unit's, quiet).
+ checks: u64 = 0,
copies: u64 = 0,
copy_bytes: u64 = 0,
divergences: u64 = 0,
@@ -227,8 +227,8 @@ const Totals = struct {
resizes: u64 = 0,
/// Clients let go by a Detach typed in their view.
detach_words: u64 = 0,
- /// Panes of each plain kind the session opened (image, pdf, life).
- kind_panes: [3]u64 = @splat(0),
+ /// Panes of each plain kind the session opened (image, life).
+ kind_panes: [2]u64 = @splat(0),
fn add(t: *Totals, s: *const replica.Stats) !void {
t.inputs += s.inputs;
@@ -240,6 +240,7 @@ const Totals = struct {
t.mispredicted += s.mispredicted;
t.foreign += s.foreign;
t.rebases += s.rebases;
+ t.checks += s.checks;
t.copies += s.copies;
t.copy_bytes += s.copy_bytes;
try t.spec_ns.appendSlice(gpa, s.spec_ns.items);
@@ -253,7 +254,7 @@ const Totals = struct {
/// a wheel over the shell pane, which scrolls its history into view; a
/// file looked at (`looks`, its words) and a pane closed, the Panes and
/// Recent pickers (the store's and Recent's rows, the authority's), a jump;
-/// a picture and a PDF looked at and a game of life opened (plain kinds a
+/// a picture looked at and a game of life opened (plain kinds a
/// client runs as the session does, `looks` past the texts), the keys
/// after going to its pane; now and then a client's Detach.
fn nextEvent(random: std.Random, buf: *[64]u8, wheel_at: ?[2]u16, looks: []const []const u8) pardes.Event {
@@ -629,7 +630,7 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
try writeFile(path, 60 + 40 * i);
look.* = try std.fmt.bufPrint(l, "Look {s}", .{path});
}
- // A picture (the image addon's) and the PDF (the pdf addon's), when
+ // A picture (the image addon's), when
// the soak has their libraries (`--addon`).
var picture: [256:0]u8 = undefined;
var nlooks: usize = 3;
@@ -643,9 +644,6 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
try writeText(path, ppm.items);
looks_buf[nlooks] = try std.fmt.bufPrint(&look_lines[nlooks], "Look {s}", .{path});
nlooks += 1;
- } else if (std.mem.eql(u8, l.name, "pdf")) if (pdf_path) |pdf| {
- looks_buf[nlooks] = try std.fmt.bufPrint(&look_lines[nlooks], "Look {s}", .{pdf});
- nlooks += 1;
};
const looks = looks_buf[0..nlooks];
// The tty's own boot (a raw shell, a text pane under it), then three
@@ -669,9 +667,9 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
}
// The picture in a column of its own: every client joins with it (a
// plain kind's pane loaded from a dump, its file read by its path), its
- // keys go to it when it has them. Not the PDF: a client joined from a
- // dump that holds one diverges at another client's key into it
- // (round 5's report: `pane N.addon`, `views[k].jumps`), open.
+ // keys go to it when it has them. Not a PDF: a client of a session that
+ // shows one diverges at a key into it (round 5's report: `pane N.addon`,
+ // `views[k].jumps`; `it breaks PA_PLAIN` after a key), open.
if (looks.len > 3) {
_ = try a.local(.{ .command = "Newcol" });
_ = try a.local(.{ .command = looks[3] });
@@ -809,7 +807,7 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
// The kinds' panes it has opened, each counted once.
for (s.a.core.panes) |slot| if (slot) |pane| if (pane.addon) |k| if (pane.serial > s.kinds_seen.*) {
s.kinds_seen.* = pane.serial;
- for ([_][]const u8{ "image", "pdf", "life" }, &s.totals.kind_panes) |name, *n| n.* += @intFromBool(k.is(name));
+ for ([_][]const u8{ "image", "life" }, &s.totals.kind_panes) |name, *n| n.* += @intFromBool(k.is(name));
};
var rows: std.ArrayListUnmanaged([]u8) = .empty;
defer rows.deinit(gpa);
@@ -2345,9 +2343,7 @@ pub fn main(init: std.process.Init) !void {
if (i + 1 >= args.len) return error.MissingValue;
i += 1;
const value = args[i];
- if (std.mem.eql(u8, name, "--seeds")) seeds = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--first")) first = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--steps")) steps = try std.fmt.parseInt(usize, value, 10) else if (std.mem.eql(u8, name, "--clients")) clients = @min(8, try std.fmt.parseInt(u16, value, 10)) else if (std.mem.eql(u8, name, "--flood")) flood_mb = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--screen-state")) screen_dir = value else if (std.mem.eql(u8, name, "--addon")) try addons.append(gpa, value) else if (std.mem.eql(u8, name, "--pdf")) {
- pdf_path = value;
- } else if (std.mem.eql(u8, name, "--rtt")) {
+ if (std.mem.eql(u8, name, "--seeds")) seeds = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--first")) first = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--steps")) steps = try std.fmt.parseInt(usize, value, 10) else if (std.mem.eql(u8, name, "--clients")) clients = @min(8, try std.fmt.parseInt(u16, value, 10)) else if (std.mem.eql(u8, name, "--flood")) flood_mb = try std.fmt.parseInt(u64, value, 10) else if (std.mem.eql(u8, name, "--screen-state")) screen_dir = value else if (std.mem.eql(u8, name, "--addon")) try addons.append(gpa, value) else if (std.mem.eql(u8, name, "--rtt")) {
var it = std.mem.tokenizeScalar(u8, value, ',');
var k: usize = 0;
while (it.next()) |v| : (k += 1) rtt_buf[k] = try std.fmt.parseInt(u64, v, 10);
@@ -2382,12 +2378,6 @@ pub fn main(init: std.process.Init) !void {
if (libc.symlink(at, try std.fmt.bufPrintSentinel(&to, "{s}/{s}", .{ lib_dir, std.Io.Dir.path.basename(lib) }, 0)) != 0) return error.NoAddon;
}
if (setenv("XDG_DATA_HOME", data, 1) != 0) return error.NoDataDir;
- // The PDF by its whole path: a Look of another is the session's directory's.
- var pdf_whole: [libc.PATH_MAX]u8 = undefined;
- if (pdf_path) |pdf| {
- var z: [600]u8 = undefined;
- pdf_path = std.mem.span(libc.realpath(try std.fmt.bufPrintSentinel(&z, "{s}", .{pdf}, 0), &pdf_whole) orelse return error.NoPdf);
- }
if (echo_mode) {
if (!try echoMain(seeds, first, rtts)) std.process.exit(1);
return;
@@ -2430,12 +2420,12 @@ pub fn main(init: std.process.Init) !void {
t.screens_checked,
t.screens_wrong,
});
- try join_lines.print(gpa, "{d:>4} {d:>5} {d:>7} {d:>8} {d:>8} {d:>6} {d:>5}/{d:<5} {d:>7} {d:>5}/{d}/{d}\n", .{ rtt, t.joins, t.refused, t.rejoined, t.detached, t.detach_words, t.agree, t.differ, t.resizes, t.kind_panes[0], t.kind_panes[1], t.kind_panes[2] });
+ try join_lines.print(gpa, "{d:>4} {d:>5} {d:>7} {d:>8} {d:>8} {d:>6} {d:>5}/{d:<5} {d:>5}/{d:<6} {d:>7} {d:>5}/{d}\n", .{ rtt, t.joins, t.refused, t.rejoined, t.detached, t.detach_words, t.agree, t.differ, t.checks, t.units, t.resizes, t.kind_panes[0], t.kind_panes[1] });
if (t.divergences > 0 or t.unequal > 0 or t.screens_wrong > 0 or t.differ > 0) failed = true;
}
std.debug.print("terminals: deltas a replica applied a second under the flood; a peer's bytes a second under the flood (deltas, units); encode a frame of the flood for every peer, apply a delta (us); rows fetched, KB of rows sent before the step that read them; resets; deltas checked/wrong\n", .{});
std.debug.print(" rtt deltas/s delta B/s unit B/s encode p50/p99 apply p50/p99 fetched filled KB resets checked/wrong\n{s}", .{term_lines.items});
- std.debug.print("clients: joins from a dump, refused (every view taken), joined again after a divergence put on them, left (of them by a Detach); quiet checks of the session's digest agreed/differed; resizes the windows posted; the kinds' panes the session opened (image/pdf/life)\n", .{});
- std.debug.print(" rtt joins refused rejoined detached detach agree/differ resizes kinds\n{s}", .{join_lines.items});
+ std.debug.print("clients: joins from a dump, refused (every view taken), joined again after a divergence put on them, left (of them by a Detach); quiet checks of the session's digest agreed/differed; the digests the clients compared (units and quiet), of the units they took; resizes the windows posted; the kinds' panes the session opened (image/life)\n", .{});
+ std.debug.print(" rtt joins refused rejoined detached detach agree/differ checks/units resizes kinds\n{s}", .{join_lines.items});
if (failed) std.process.exit(1);
}