summaryrefslogtreecommitdiff
path: root/src/tape.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 16:00:52 -0300
committerGabriel Schneider <[email protected]>2026-10-30 20:25:56 -0300
commit6cb07327b717603be983fdd6df0e6d9009aae39a (patch)
tree7a8519b0ddb7292ac2042f2b95e49998c4c36d4d /src/tape.zig
parent97431acd8e77410dbaea9fb1093d29327999cd5b (diff)
downloadpardes-6cb07327b717603be983fdd6df0e6d9009aae39a.tar.gz
pardes-6cb07327b717603be983fdd6df0e6d9009aae39a.zip
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 <[email protected]>
Diffstat (limited to 'src/tape.zig')
-rw-r--r--src/tape.zig15
1 files changed, 11 insertions, 4 deletions
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();