From c9ac46755632d5cd1bdc34fe211112d730ffc77f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 01:21:25 -0300 Subject: replica: a client measures how far behind its session it is and past two seconds lets its link go and joins again from a dump, saying so once (P32 (b); step 3, item 2): the fault shown first (a client whose units came 2.1 s later than its quickest took them on: Link.quit false) and in the soak (the far client never let go: one join, its final screen 17.7 s after the flood's end); Link.behind, each unit's head's session clock against the client's own (Link.time), less the smallest difference seen; one constant, behind_max_ms = 2,000, near and far; past it the link let go (the bye's `again`, its view kept), the notice "joined again: N.N s behind" (Link.rejoins), the first unit after a join past it taken as the link now (a session's clock stood still while its machine slept; a dump that took longer than the bound: never a let-go at once, never a loop); the clock is the client's machine's, read in Link alone (no new line on root.zig's machine_lines; Link is no part of Pardes, so no digest or dump reaches it); a test that fed a simulated client clock with units of the real clock made them on its own clock; the soak counts the let-gos and how far behind each client fell; tui core-test 859/1009 (150 skipped), shell-test 1045/1048, term-test 17/17; the soak, screen state (--clients 5, 4 seeds): diverged 0, unequal 0, deltas 7093/0 7518/0 7603/0, quiet 590/0 472/0 541/0, unlisted 0, corpus 22 of 22, the far client 9/9/7 let-gos, others 0; bytes (--seeds 8): the far client shows its final screen in every run, 6.5-7.9 s after the flood's end, refreshed every 7.0-7.3 s (p50), others 0 let-gos and 2-10 ms behind at most, quiet 1077/0 1083/0 1457/0, unequal 0, BUT 5/3/1 near clients diverged at joins (reports/pardes-term-lag.md: open); ReleaseFast (2 seeds, 80 ms): 0 diverged, a join's unit on a client already there 9.6 ms p50, 17.7 ms at worst, the session's join step 1.4/14.3 ms Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/replicas.zig | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/replicas.zig b/test/replicas.zig index 637af0b3..5cddf6c8 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -284,6 +284,12 @@ const Totals = struct { far_final: std.ArrayListUnmanaged(u64) = .empty, queue_max: u64 = 0, cut: u64 = 0, + /// How far behind the session each fell at most (Link.behind, ns), and + /// how often it let its link go for it: the far client, and the others. + far_behind: u64 = 0, + far_lags: u64 = 0, + near_behind: u64 = 0, + near_lags: u64 = 0, /// What a join costs the replicas already there, ns of this process's /// clock: the session's join step (its reloads and its dump), and each /// client's unit that reloaded its terminals. @@ -760,9 +766,12 @@ fn ended(cl: *Client, c: usize, net: *Net, now: u64, totals: *Totals, run_: Run, const r = cl.r.?; const link = &cl.loop.link; // Its link ended by the session (a Detach), it says nothing more. - if (!link.gone) replica.bye(link.fd, r.diverged != null); + if (!link.gone) replica.bye(link.fd, r.diverged != null or link.lagged != 0); try drain(cl, c, net, now); cl.live = 0; + if (link.lagged != 0) { + if (net.throttled == @as(?usize, c)) totals.far_lags += 1 else totals.near_lags += 1; + } if (r.diverged) |why| { if (link.put_off) totals.rejoined += 1 else { totals.divergences += 1; @@ -1515,6 +1524,8 @@ const Soak = struct { const t0 = monoNs(); cl.loop.take(.{ .unit = try std.heap.c_allocator.dupe(u8, m.bytes) }); if (pardes.Term.reloads.n != reloads) try s.totals.join_client_ns.append(gpa, monoNs() - t0); + const behind = if (net.throttled == @as(?usize, c)) &s.totals.far_behind else &s.totals.near_behind; + behind.* = @max(behind.*, cl.loop.link.behind); }, .word => cl.loop.take(.{ .refused = try std.heap.c_allocator.dupe(u8, m.bytes) }), .blob => cl.loop.take(.{ .blob = try std.heap.c_allocator.dupe(u8, m.bytes) }), @@ -3082,16 +3093,20 @@ pub fn main(init: std.process.Init) !void { for (t.stops) |st| if (st.n > 0) try stop_lines.print(gpa, "{s}:{d} ", .{ st.name, st.n }); try stop_lines.append(gpa, '\n'); 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}/{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], t.kind_panes[2] }); - try far_lines.print(gpa, "{d:>4} {d:>5} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} {d:>8} {d:>3} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} ({d})\n", .{ - rtt, t.far_joins, + try far_lines.print(gpa, "{d:>4} {d:>5} {d:>4} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} {d:>8} {d:>3} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} ({d}) {d:>6.0}/{d:<6.0} {d}\n", .{ + rtt, t.far_joins, t.far_lags, secs(pct(t.far_gaps.items, 50)), secs(pct(t.far_gaps.items, 100)), secs(pct(t.far_final.items, 50)), secs(pct(t.far_final.items, 100)), t.queue_max >> 10, t.cut, msOf(pct(t.join_session_ns.items, 50)), msOf(pct(t.join_session_ns.items, 100)), msOf(pct(t.join_client_ns.items, 50)), msOf(pct(t.join_client_ns.items, 100)), t.join_client_ns.items.len, + msOf(t.far_behind), msOf(t.near_behind), + t.near_lags, }); - if (t.far_final.items.len < seeds and clients >= 5) failed = true; + // The far client shows the final screen in every run, and the near + // ones never fall behind with it. + if ((t.far_final.items.len < seeds and clients >= 3) or t.near_lags > 0) failed = true; if (t.divergences > 0 or t.unequal > 0 or t.screens_wrong > 0 or t.differ > 0 or t.unlisted > 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", .{}); @@ -3100,8 +3115,8 @@ pub fn main(init: std.process.Init) !void { std.debug.print(" rtt joins refused rejoined detached detach agree/differ checks/units resizes kinds\n{s}", .{join_lines.items}); std.debug.print("stops: the wakes the clients' loops asked, the frames they drew, the yanks, pastes and links their frontends did (y/p/l), and what stopped their inputs (a stop counted again as its input is applied again), by name; those at a name replica.may_wait does not list fail the run\n", .{}); std.debug.print(" rtt unlisted wakes draws y/p/l stops\n{s}", .{stop_lines.items}); - std.debug.print("far: the third client's link 1 Mbit/s and 200 ms each way (zstd's bytes): its joins from a dump, s between two from the flood's start (p50/max), s from the flood's end to its final screen (p50/max: a run that never shows it fails), the session's queue for it at most, clients cut off; a join's cost to the replicas there before it, ms on this process's clock (p50/max): the session's step (reloads and dump), a client's unit (reloads), how many\n", .{}); - std.debug.print(" rtt joins refresh s final s queue KB cut session ms client ms\n{s}", .{far_lines.items}); + std.debug.print("far: the third client's link 1 Mbit/s and 200 ms each way (zstd's bytes): its joins from a dump, of them for its lag (Link.behind past replica.behind_max_ms), s between two from the flood's start (p50/max), s from the flood's end to its final screen (p50/max: a run that never shows it fails), the session's queue for it at most, clients cut off; a join's cost to the replicas there before it, ms on this process's clock (p50/max): the session's step (reloads and dump), a client's unit (reloads), how many; ms behind the session at most (Link.behind), the far client and the others, and the others' joins for it (0, or the run fails)\n", .{}); + std.debug.print(" rtt joins lags refresh s final s queue KB cut session ms client ms behind far/near ms\n{s}", .{far_lines.items}); if (failed) std.process.exit(1); } -- cgit v1.3