From 6cb07327b717603be983fdd6df0e6d9009aae39a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 16:00:52 -0300 Subject: replica: what stopped each input's speculation is counted by name (PARDES_REPLICA_STATS's `stops`: a host function's, a site's, or a poison's reason, which tape.poison now takes; PARDES_REPLICA_TRACE says it with the input); a window client's PARDES_TEST_LATENCY says each input (`I seq ns at-once`) and, after each unit, the first of its own not confirmed (`U ns seq`), so a harness finds the frame that shows an input that waited Co-Authored-By: Claude Opus 5.5 --- src/tape.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/tape.zig') diff --git a/src/tape.zig b/src/tape.zig index 1ca064bc..7b7c02f2 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -216,6 +216,9 @@ pub const Tape = struct { /// checks. speculating: bool = false, poisoned: bool = false, + /// What stopped it: a host function's or a site's name, or a poison's + /// reason (PARDES_REPLICA_STATS counts them). + poisoned_by: []const u8 = "", /// The allocator of the core a replay makes (a replica's rollback epoch, /// src/rollback.zig), when it is not the tape's own. core_gpa: ?std.mem.Allocator = null, @@ -801,6 +804,7 @@ fn hostCall(comptime i: usize, comptime R: type, ctx: ?*anyopaque, args: anytype return r; } t.poisoned = true; + t.poisoned_by = name; return poisonOf(R); } const real = @field(t.real.vtable.*, name).?; @@ -839,7 +843,7 @@ pub fn value(comptime s: Site, comptime f: anytype, args: anytype) @typeInfo(@Ty /// lives to the step's end (scratch, or the authority's own), and the /// caller copies what it keeps. pub fn authority(comptime f: anytype, args: anytype) @typeInfo(@TypeOf(f)).@"fn".return_type.? { - poison(); + poison("the authority's own state"); return value(.authority, f, args); } @@ -872,6 +876,7 @@ fn call(comptime s: Site, a: ?std.mem.Allocator, comptime f: anytype, args: anyt // the authority's answer. if (yields and t.speculating) { t.poisoned = true; + t.poisoned_by = @tagName(s); return poisonOf(R); } if (comptime s == .clock or s == .mtime) if (t.speculating) if (t.guess) |g| { @@ -995,11 +1000,12 @@ pub fn screenAuthority() bool { return if (on) |t| t.screen_state and !t.replay and !t.speculating else false; } -/// What a speculation reached is the authority's: the input is undone and -/// waits for the authority's order. -pub fn poison() void { +/// What a speculation reached is the authority's (`why`): the input is +/// undone and waits for the authority's order. +pub fn poison(why: []const u8) void { if (on) |t| if (t.speculating) { t.poisoned = true; + t.poisoned_by = why; }; } @@ -1098,6 +1104,7 @@ pub fn beginSpeculation(t: *Tape) void { t.replay = false; t.speculating = true; t.poisoned = false; + t.poisoned_by = ""; t.no_digest = true; t.buf.clearRetainingCapacity(); t.seeFields(); -- cgit v1.3