summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 10:10:27 -0300
committerGabriel Schneider <[email protected]>2026-11-18 11:03:32 -0300
commit30a2426271007992176ad5cd25fb36b77c8b68f2 (patch)
tree9cc04b3e8c41bcc3029a058aacf53348a0fe78a6 /src/replica.zig
parent5c5e0102f92938f433a3465c92818be810c1ef78 (diff)
downloadpardes-30a2426271007992176ad5cd25fb36b77c8b68f2.tar.gz
pardes-30a2426271007992176ad5cd25fb36b77c8b68f2.zip
replica: a copy taken ahead (Replica.ready, when the client is idle) is let go once the session's next unit is replayed over it, not held over the session's units and kept in since to replay at a rollback: the soak (test/replicas.zig) never called ready, and calling it after each unit as both clients do when idle (tui.zig, gui.zig) made two of three replicas diverge at once (seed 0 and 1, rtt 30: digest differs in panes, views, views[2].jumps, pane 0.body, pane 1.cwd after another client's mouse release, four texts unequal at quiescence; 0 with one or two clients); every rollback's state checked against the last confirmed unit's digest agreed, so what the held copy put back stale is state no digest covers, not found yet; the soak calls ready now. tty, ReleaseFast, 50,000-line file, client instructions before -> after, own unchanged: key-down 6.37M -> 6.38M (own 3.86M), type 17.25M -> 17.26M, edit 20.36M -> 20.37M, resize 8.26M -> 8.28M, open 68.53M -> 68.57M, page-down 49.28M -> 45.38M, cat 20k 118.3M -> 97.5M (both noisy; load 3-12); replicas pass (3 clients, ready called), core-test 819/958, shell-test 993/996, behaviour-test 273/273 and --replay 20 seeds 0 failures, pane-test 180/181, process-test 2 of 144 (lspcomplete, lspcompletemoved), gui unit-test 1586/1590 (BaselineBuildMismatch), corpus 77/77 (Debug), daemon.py plain, --far, --window-clients
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 2a5404c5..a7e6c04e 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -852,10 +852,12 @@ pub const Replica = struct {
const u = parseUnit(msg) orelse return r.fail("a unit too short to read");
r.stats.units += 1;
if (u.origin == r.id) if (r.t.core) |c| r.echo.confirmed(c, u.seq);
- // A copy taken ahead (`ready`), nothing on top: it stays the point a
- // rollback goes back to, the unit replayed on it and kept in `since`,
- // not let go and taken again (a megabyte walked) for each unit of
- // the session's that comes while the client is idle.
+ // A copy taken ahead (`ready`), nothing on top: let go once the unit
+ // is replayed, and taken again when the client is idle. Held over
+ // the session's units, kept in `since` to replay, it put back a
+ // state a later step read otherwise than the session's (the soak,
+ // three clients, with `ready` as the clients call it: diverged; every
+ // rollback's digest agreed, so what differs is no digest's).
const ahead = r.applied == 0 and r.copy.held;
if (r.guess) {
r.stamp = .{ .real_ns = u.real_ns, .mono_ns = u.mono_ns, .at_ns = nowNs() };
@@ -943,7 +945,11 @@ pub const Replica = struct {
r.freePending(r.pending.orderedRemove(0));
}
r.dirty = true;
- if (ahead) r.keepSince(u.tape);
+ if (ahead) {
+ r.copy.release();
+ rollback.Epoch.select(null);
+ r.clearSince();
+ }
}
fn fail(r: *Replica, why: []const u8) void {