summaryrefslogtreecommitdiff
path: root/src/rollback.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 21:45:19 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:45:19 -0300
commit473bbaa838f290e932992ef625be2fdc05c952dc (patch)
tree3165ffa9af3e9c0c3e777d012228cc033c1bbf80 /src/rollback.zig
parent64184a16e58094f6b861cd1027920ddf21d9df0d (diff)
downloadpardes-473bbaa838f290e932992ef625be2fdc05c952dc.tar.gz
pardes-473bbaa838f290e932992ef625be2fdc05c952dc.zip
screen-state replicas: what a terminal's ingest tells the positions pardes keeps over it taped, the history a step reads sent before its unit, rows sent a blob once a message, and the rows cache out of the rollback copy
terminal.zig, tape.zig: ingestWithPositions tracks its rows only where an ingest happens; what the ingest told them (each tracked row's row after it and whether it was erased, a clear, whether the pages lived, a pin not made) is a taped value (Site.positions), which a screen-state replica, ingesting nothing, takes; the logic after it runs alike on both. On the stack, so the local path allocates nothing new. buildRows marks a terminal read (State.read) outside the render (terminal.drawing). screen_state.zig, replica.zig: the authority keeps each peer's holes as its replica does (Peer.holes, from the deltas it sent), and Screens.fill sends a peer the rows it lacks of every terminal a step read, after the step and before its unit, so a replay reads what the step read (a text-mode cursor moved into history the flood scrolled past diverged). encodeRows sends each distinct blob once a message and the rows as addresses (a fill after yes is a third). The rows cache is dropped when a copy is taken and emptied when it is put back, not saved. test/replicas.zig: Ctrl-b in the mix (a shell out of tty mode: text, cursors and selections over it), and a shell's session (prompts, titles, directories, clears) between the TUI and the flood. 4 seeds x 120 inputs x 3 clients at 30, 80, 207 ms: no divergence, every replica and terminal the authority's, 4,653 deltas checked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/rollback.zig')
-rw-r--r--src/rollback.zig13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rollback.zig b/src/rollback.zig
index b5f4e966..d87671e6 100644
--- a/src/rollback.zig
+++ b/src/rollback.zig
@@ -350,7 +350,7 @@ pub const Copy = struct {
// the speculation freed would come back as that. Not the
// queues a step drains (undefined between steps), nor the
// authority's.
- if (attr.@"comptime" or comptime (annotated(T, "authority", name) or (annotated(T, "local", name) and unsaved(name)))) continue;
+ if (attr.@"comptime" or comptime (annotated(T, "authority", name) or ((annotated(T, "local", name) or annotated(T, "derived", name)) and unsaved(name)))) continue;
if (comptime opaqueTo(F)) continue;
c.where = @typeName(T) ++ "." ++ name;
c.pinnable = comptime pinned(T, name);
@@ -390,7 +390,7 @@ pub const Copy = struct {
const s = @typeInfo(T).@"struct";
inline for (s.field_names, s.field_types, s.field_attrs) |name, F, attr| {
if (attr.@"comptime") continue;
- if (comptime annotated(T, "local", name) and unsaved(name)) continue;
+ if (comptime (annotated(T, "local", name) or annotated(T, "derived", name)) and unsaved(name)) continue;
const at = @intFromPtr(&@field(v, name));
if (comptime walk.lengthOf(T, name) != null and @typeInfo(F) == .array) {
try c.save(at, walk.lengthIn(v, comptime walk.lengthOf(T, name).?) * @sizeOf(@typeInfo(F).array.child));
@@ -429,10 +429,13 @@ fn annotatedStruct(comptime T: type) bool {
}
/// The queues every step drains (empty between steps, asserted when a copy
-/// is taken: what is in their slots is nothing), and the frame statistics
-/// (numbers, and a static name).
+/// is taken: what is in their slots is nothing), the frame statistics
+/// (numbers, and a static name), and the rows a terminal was last read as
+/// (a grid's worth of text, emptied when a copy is taken and when it is
+/// put back: src/replica.zig).
fn unsaved(comptime name: []const u8) bool {
- return std.mem.eql(u8, name, "effects") or std.mem.eql(u8, name, "in_q") or std.mem.eql(u8, name, "frames");
+ return std.mem.eql(u8, name, "effects") or std.mem.eql(u8, name, "in_q") or std.mem.eql(u8, name, "frames") or
+ std.mem.eql(u8, name, "shell_rows");
}
fn annotated(comptime T: type, comptime kind: []const u8, comptime name: []const u8) bool {