summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 01:36:47 -0300
committerGabriel Schneider <[email protected]>2026-11-20 01:36:47 -0300
commit11f55f018a5eb0699d58627a4f2ea39c2b7f5e89 (patch)
tree79b8e6353a2a71a6578f415401e00ac0fc6da681 /test
parentcdff9d3a854aa8fd434b77ad6ac5a9db3efa3707 (diff)
parent7ec8b0fc4486b0fd1807c344dd0a4b38f325db30 (diff)
downloadpardes-11f55f018a5eb0699d58627a4f2ea39c2b7f5e89.tar.gz
pardes-11f55f018a5eb0699d58627a4f2ea39c2b7f5e89.zip
integration: the per-operation gate sees the client path: pardes-perf-cells (three client cells in pardes-perf: client-key-down, client-edit-char, client-delete-undo: a replica and its session in one process) on pardes-merge27; test/perf.zig only; the gate's base recorded anew from this tree (gpu/tree2), since the cells change what a full run holds
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/perf.zig75
1 files changed, 72 insertions, 3 deletions
diff --git a/test/perf.zig b/test/perf.zig
index 880e6abe..7920dedf 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -41,10 +41,17 @@ const Op = enum {
open,
render,
key_down,
+ /// key_down's key through a near client and its session in one process
+ /// (`measureClient`): the pair's count.
+ client_key_down,
key_right,
page_down,
wheel,
edit_char,
+ client_edit_char,
+ /// A delete and its undo on the saved file (d, u: the terminal kit's
+ /// `edit`), through a near client and its session.
+ client_delete_undo,
/// edit_char with a Zerox twin open on the same file: the twin takes
/// the splice, not a copy of the text (File.setContentSpan).
edit_twin,
@@ -69,10 +76,13 @@ const Op = enum {
.open => "open",
.render => "render",
.key_down => "key-down",
+ .client_key_down => "client-key-down",
.key_right => "key-right",
.page_down => "page-down",
.wheel => "wheel",
.edit_char => "edit-char",
+ .client_edit_char => "client-edit-char",
+ .client_delete_undo => "client-delete-undo",
.edit_twin => "edit-twin",
.body_write => "body-2m",
.body_appends => "body-appends",
@@ -565,7 +575,11 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
const samples = try gpa.alloc(u64, reps);
defer gpa.free(samples);
- if (op == .image_frame) return measureImage(std.fs.path.dirname(path).?, samples, warmup);
+ switch (op) {
+ .image_frame => return measureImage(std.fs.path.dirname(path).?, samples, warmup),
+ .client_key_down, .client_edit_char, .client_delete_undo => return measureClient(op, path, reps),
+ else => {},
+ }
if (op == .open) {
for (0..warmup + reps) |n| {
const core = try boot();
@@ -618,7 +632,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
const wheel_row = rect.y + pardes.BOX_H;
const t0 = nowNs();
switch (op) {
- .open, .image_frame => unreachable,
+ .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable,
.render, .deep_selection => {},
.key_down => core.update(.{ .key = .{ .cp = 'j', .text = "j" } }),
.key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }),
@@ -632,7 +646,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
_ = try frame(core);
const dt = nowNs() -| t0;
switch (op) {
- .open, .image_frame => unreachable,
+ .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable,
.body_write => if (pane.file.?.content.len != before.len + 8 * body_chunk.len) return error.BodyWriteWasNotAppended,
.body_appends => if (pane.file.?.content.len != before.len + append_count * append_chunk_len) return error.BodyAppendsWereNotAppended,
.render, .deep_selection => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col or pane.file.?.content.len != before.len)
@@ -660,6 +674,61 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
return summarize(samples);
}
+/// The keys of a client cell's gesture: a key down, a character typed in
+/// insert mode, a delete undone (two keys).
+fn clientKeys(op: Op) []const pardes.Event {
+ return switch (op) {
+ .client_key_down => &.{.{ .key = .{ .cp = 'j', .text = "j" } }},
+ .client_edit_char => &.{.{ .key = .{ .cp = 'x', .text = "x" } }},
+ .client_delete_undo => &.{ .{ .key = .{ .cp = 'd', .text = "d" } }, .{ .key = .{ .cp = 'u', .text = "u" } } },
+ else => unreachable,
+ };
+}
+
+const client_host_vtable = pardes.replica.everyEntry(.{});
+
+/// A near client's gesture through a replica of a session in this process
+/// (core/replica.zig), in the live pair's order: the key applied on the
+/// client at once, the session's pump unit (it moved nothing) and the
+/// key's own unit confirmed, the client's frame. The count is the pair's,
+/// the session's step and the client's; one order of arrival, so what
+/// depends on another (a unit of another client's, a late one) it does
+/// not see.
+fn measureClient(op: Op, path: []const u8, reps: usize) !Cell {
+ const warmup = 3;
+ const samples = try gpa.alloc(u64, reps);
+ defer gpa.free(samples);
+ const a = try pardes.replica.Authority.init(gpa, .{ .tty_only = true, .file = path, .cols = screen_cols, .rows = screen_rows }, .{ .vtable = &client_host_vtable }, false);
+ defer a.deinit();
+ const r = try pardes.replica.Replica.init(gpa, 1, try a.unit(0, 0), false);
+ defer r.deinit();
+ // Idle first, as a client is: its copy taken ahead and a pump's unit of
+ // the session's kept over it. Two units kept a key after that put the
+ // kept list's bound on a pump's unit, under a key applied: the arrival
+ // a client's rollback copy is dearest on (core/replica.zig keepSince).
+ r.ready();
+ a.pump();
+ r.confirm((try a.pending()).?);
+ if (op == .client_edit_char) try clientKey(a, r, .{ .key = .{ .cp = 'i', .text = "i" } });
+ for (0..warmup + reps) |n| {
+ const t0 = nowNs();
+ for (clientKeys(op)) |ev| try clientKey(a, r, ev);
+ _ = r.draw(.{ .ctx = null, .f = null });
+ if (n >= warmup) samples[n - warmup] = (nowNs() -| t0) / 1000;
+ }
+ if (r.diverged != null or r.stats.mispredicted != 0 or !r.quiet() or r.digest() != pardes.replica.digestOf(a)) return error.ClientDiverged;
+ return summarize(samples);
+}
+
+fn clientKey(a: *pardes.replica.Authority, r: *pardes.replica.Replica, ev: pardes.Event) !void {
+ const msg = try gpa.dupe(u8, try r.input(ev));
+ defer gpa.free(msg);
+ a.pump();
+ r.confirm((try a.pending()).?);
+ r.confirm(try a.take(msg));
+ r.settle();
+}
+
fn measureImage(dir: []const u8, samples: []u64, warmup: usize) !Cell {
const path = try std.fmt.allocPrint(gpa, "{s}/picture.ppm", .{dir});
defer gpa.free(path);