From 97f83717cf8be3e4eedd3f7b932766c1cf72fd37 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 10:46:16 -0300 Subject: perf --live: keystroke-to-present through the real tty and GUI, `yes | head -c 1G` through a real pty, and a big file's open The baseline the daemon work is measured against (docs/next-daemon.md). `pardes-perf --live ` runs the real tty binary in a pty (test/e2e_harness.zig, as the snapshot harness does): FrameStats.keys's gestures (key-down, key-right, edit-char, page-down, wheel) on the 50k-line fixture, a phase each, each frame's latency from the shell taking the input off its queue to the end of its present, read back from the session's PARDES_FRAMES dump; `yes | head -c 1G` typed into a bash pane in tty mode, wall time to the mark after it and the frames drawn; and a 1,000,000-line file opened on the command line, wall time to its first line on screen. `--live-gui ` runs the same gestures as the GUI's own timedemo (PARDES_FRAMES_DEMO=keys) in a hidden test window. p50 and p99 per phase, pooled over --reps runs; text or --json. Each run has a private home (bash with a `$ ` prompt), XDG_RUNTIME_DIR and fixtures under $TMPDIR, all removed after. The frames dump now says the monotonic time of its first frame (`# t0_ns`), so a driver lines its own phase times up with the frames'. The perf gate's baselines (test/perf-baseline-{tty-debug,tty-fast,gui-debug}.json) are recorded again: the harness id is perf.zig's hash, and the medium cells came out within about 10% of the old ones (edit-char and edit-twin faster). Co-Authored-By: Claude Opus 5.5 --- src/FrameStats.zig | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/FrameStats.zig') diff --git a/src/FrameStats.zig b/src/FrameStats.zig index cabb003b..2287002e 100644 --- a/src/FrameStats.zig +++ b/src/FrameStats.zig @@ -269,6 +269,9 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void { } write.line(fd, &buf, "# start_ms\tupdate_us\trender_us\tpresent_us\tgap_us\tmoving\tskipped\tscroll\n", .{}); const t0 = if (all[0].len != 0) all[0][0].start_ns else 0; + // The monotonic clock is the machine's: a driver lines its own times + // up with the frames' by this. + write.line(fd, &buf, "# t0_ns {d}\n", .{t0}); // The timedemo's phases, on the frames' clock. if (stats.demo_ns != 0) if (named(stats.demo_name)) |steps| for (steps) |step| switch (step.act) { .phase => |name| write.line(fd, &buf, "# phase {s} {d:.1}\n", .{ name, @as(f64, @floatFromInt((stats.demo_ns + @as(u64, step.at_ms) * std.time.ns_per_ms) -| t0)) / std.time.ns_per_ms }), @@ -328,6 +331,7 @@ pub fn named(name: []const u8) ?[]const Step { if (std.mem.eql(u8, name, "pdf-scroll")) return &pdf_scroll; if (std.mem.eql(u8, name, "pdf-sdm")) return &pdf_sdm; if (std.mem.eql(u8, name, "one")) return &one; + if (std.mem.eql(u8, name, "keys")) return &keystrokes; if (std.mem.eql(u8, name, "jumps")) return &jumps; if (std.mem.eql(u8, name, "longlines")) return &longlines; if (std.mem.eql(u8, name, "clip-flick")) return &clip_flick; @@ -592,6 +596,56 @@ pub const pdf_sdm = blk: { break :blk out; }; +/// Keystroke-to-present, a phase a gesture, on the file the session opened: +/// test/perf.zig's --live sends these same steps to the tty through a pty +/// and --live-gui runs them here, so the two frontends are timed alike. +pub const keystrokes = blk: { + @setEvalBranchQuota(50_000); + var steps: [1024]Step = undefined; + var n: usize = 0; + var t: u32 = 1500; + const at = struct { + fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void { + s[k.*] = .{ .at_ms = ms, .act = act }; + k.* += 1; + } + }; + at.add(&steps, &n, t, .{ .phase = "key-down" }); + for (0..150) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = 'j', .text = "j" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .phase = "key-right" }); + for (0..150) |i| { + at.add(&steps, &n, t, .{ .key = if (i % 2 == 0) .{ .cp = 'l', .text = "l" } else .{ .cp = 'h', .text = "h" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .phase = "edit-char" }); + at.add(&steps, &n, t, .{ .key = .{ .cp = 'i', .text = "i" } }); + t += 30; + for (0..150) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = 'x', .text = "x" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.escape } }); + t += 300; + at.add(&steps, &n, t, .{ .phase = "page-down" }); + for (0..60) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } }); + t += 50; + } + at.add(&steps, &n, t, .{ .phase = "wheel" }); + for (0..150) |_| { + at.add(&steps, &n, t, .{ .wheel = 1 }); + t += 30; + } + t += 500; + at.add(&steps, &n, t, .{ .phase = "done" }); + at.add(&steps, &n, t, .end); + const out = steps[0..n].*; + break :blk out; +}; + /// `scrollSet` alone, on the file the session opened: one kind, for a /// profiler's run. pub const one = blk: { -- cgit v1.3