diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 15:15:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 17:38:19 -0300 |
| commit | 2de6284791f30ecb3bcc45fa58571418a07ac6e5 (patch) | |
| tree | 175e2977e5c1696d5b409a239e79aa016caeabe6 /core/replica.zig | |
| parent | 3ba1f19edb70494fc7f6b053e9c5c26c9e1daeca (diff) | |
| download | pardes-2de6284791f30ecb3bcc45fa58571418a07ac6e5.tar.gz pardes-2de6284791f30ecb3bcc45fa58571418a07ac6e5.zip | |
replica: a client presents a frame only when a unit's steps asked for one, as the session's own frontend draws (Pardes.pump returns idle while `!needs_frame`), not whenever a unit moved the session's digest: "Pet cat" written to /ctl is two units (the write and the close), each moved the digest, and a client window drew the pet twice (the corpus's frames 45 and 46 one picture, every later frame shifted by one); `Replica.confirm` marks `moved` when the replayed unit left `needs_frame` set, read AFTER `tape.replayUnit` (before it, it is what the units before asked, and a replica's first unit has no core yet: `Replica.init` crashed on a null core), and `Replica.draw` clears `needs_frame` for a client's replica (`skips_render`: its replay is never watched, so never clears it, and replays nothing that reads it) while an in-process replica (the tests', test/perf.zig's client cells) keeps it as its replay of its session's own drawing left it (cleared, that replay skipped a host call its tape has: "diverged: the core did not make the host call 5"); a user's client no longer presents a frame for a unit that asked none (a ctl write's close, a clock read): CPU only, no picture changes; test: "a client marks its view moved for a unit of the session's whose steps asked for a frame, and not for one whose steps asked none" (a client joined as a dial joins: the session's key marks it, its pump with nothing to step does not; failed with the line before the replay, crashed as pair-7 left it); core-test 896/1056 (160 skipped), shell-test 1098/1101 (3 skipped) (+1 each); the screen-state soak `--clients 5` diverged 0, unequal 0 at 30/80/207 ms, quiet checks 510/0, 469/0, 545/0, unlisted 0, the corpus scene 22 of 22, no leak; daemon.py on Debug plain 3 of 3, --clients 3 of 3, --games (snake and life in two clients, keys stopped 0 of 153 and 0 of 152) (loads 4-8); the frame and perf gate against tree3 (gpu/pair8-g1): 77/77 frames byte-identical, gui unit-test 1695/1699, perfab corpus2x +0.087% (noise 0.072%), 121 counts within 0.1% (largest client-key-down on large +0.0705%); the corpus through a client window as a pair: frames 0-49 byte-identical to tree3's (the pet one frame), where the scene with a kitty image stops a screen-state client (the terminals' line's)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/core/replica.zig b/core/replica.zig index 3e6be763..cbb64363 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -1022,10 +1022,6 @@ pub const Replica = struct { r.toConfirmed(); if (r.diverged != null) return; } - // What it shows moved only when what a digest covers did: a unit of - // the session's pump that read its clock and moved nothing draws - // no frame. - if (ends == null or !std.mem.eql(u8, ends.?, r.last_digest.items)) r.moved = true; // What the unit opens or closes outside the copy (`keepSince` below). var serials: [pardes.MAX_PANES]u32 = undefined; var retiring = false; @@ -1045,6 +1041,13 @@ pub const Replica = struct { trace(r.gpa, "replica {d}: the unit of {d}/{d} diverged: {s}\n", .{ r.id, u.origin, u.seq, why }, &.{u.tape}); return r.fail(why); } + // What it shows moved only when the unit's steps asked for a frame, + // as the session's own frontend draws (Pardes.pump): a pump that + // read its clock and stepped none, a 9P request that changed no + // pane (the close after a ctl write: its frame was drawn again), + // draw nothing. Read after the replay: before it, it is what the + // units before asked (and a first unit has no core yet). + if (r.core().needs_frame) r.moved = true; if (check) { r.since_check = 0; r.stats.checks += 1; @@ -1299,9 +1302,12 @@ pub const Replica = struct { pub fn draw(r: *Replica, present: pardes.views.Present) bool { rollback.Epoch.select(&r.epoch); defer rollback.Epoch.select(null); - // A frame drawing owes another is this process's, not the core's. + // A client's replica (`skips_render`) is never watched in its + // replay, which so never clears `needs_frame`: the frame its steps + // asked for is this one. One in process replays its session's own + // drawing (Pardes.pump), which reads and clears it as the session's. const c = r.core(); - const needs = c.needs_frame; + const needs = c.needs_frame and !r.t.skips_render; defer c.needs_frame = needs; return pardes.views.drawOne(c, r.view, present) catch true; } @@ -4140,6 +4146,28 @@ test "the copy taken for an input of its own stays once the input is confirmed: try std.testing.expectEqual(@as(u32, 1), r.stats.foreign); } +test "a client marks its view moved for a unit of the session's whose steps asked for a frame, and not for one whose steps asked none" { + // The own frontend's rule (Pardes.pump): a unit that only read the + // clock, or a ctl write's close, draws nothing; a client presented it + // again (the corpus's pet: one picture twice). + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); + defer a.deinit(); + // A client as a dial joins it: it draws none of its replay. + const r = try joinedNow(a, 1, 0); + defer r.deinit(); + _ = r.draw(.{ .ctx = null, .f = null }); + r.moved = false; + r.confirm(try a.local(.{ .key = .{ .cp = 'l', .text = "l" } })); + try std.testing.expect(r.moved); + _ = r.draw(.{ .ctx = null, .f = null }); + r.moved = false; + a.pump(); + r.confirm((try a.pending()).?); + try std.testing.expect(!r.moved); + try agrees(a, r); +} + test "the session's pump units that moved nothing, kept under a key applied on top, reach the kept list's bound: it is let go at the confirm that leaves nothing applied, never replayed whole" { // The live pair's order (core/replica.zig Peers.boundary): before it // steps a client's key the session sends its pump's unit, which moved |
