diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 19:50:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 19:57:27 -0300 |
| commit | dce94f4453735a6f71385cc020ee79c7604609e7 (patch) | |
| tree | 266e031b92a282187467f5e35c1b0824b4b7a5f2 /test/perf.zig | |
| parent | 2868516c215a96d9e1e933ded7ac5744ec16c368 (diff) | |
| download | pardes-dce94f4453735a6f71385cc020ee79c7604609e7.tar.gz pardes-dce94f4453735a6f71385cc020ee79c7604609e7.zip | |
Zerox opens a second pane on a file pane's buffer: one text, undo and unsaved state, a scroll and a cursor each; an edit in either is spliced into both at File.setContentSpan, O(the edit) more, and what a Save, a get, the disk watch or a rename changes on one is copied to the rest after each step
Twins share the content buffer, the History and, while it is one, the line
index; the other twin's cursor and scroll move past the splice as acme
moves a clone's q0. Del of one twin asks nothing while another holds the
text, Exit lists the text once, and a closed twin keeps a copy of its own
until it is torn down. Both are in the index, each its serial, one name.
An event reader on one hears no edit made through another (first cut).
A dump keeps the twins as two panes on the file, not linked again.
perf: edit-twin, typing beside a twin of the 50k-line file, gated within
3x of edit-char in the same run; the three baselines re-recorded for it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/perf.zig')
| -rw-r--r-- | test/perf.zig | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/test/perf.zig b/test/perf.zig index 94076a25..c9235954 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -46,6 +46,9 @@ const Op = enum { page_down, wheel, edit_char, + /// 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, /// 2 MB appended to the file through 9P, on one open, in 256 KB /// writes: linear, not a copy of the whole buffer per write. body_write, @@ -67,6 +70,7 @@ const Op = enum { .page_down => "page-down", .wheel => "wheel", .edit_char => "edit-char", + .edit_twin => "edit-twin", .body_write => "body-2m", .body_appends => "body-appends", .deep_selection => "deep-sel", @@ -511,6 +515,19 @@ fn gate(cells: *const [std.enums.values(Op).len][fixtures.len]Cell, base: *const failed = true; } }; + // Typing beside a twin costs about what typing alone does, whatever the + // baseline: the twin takes the splice, never a copy of the text. + const twin_op = @intFromEnum(Op.edit_twin); + const alone_op = @intFromEnum(Op.edit_char); + for (fixtures, 0..) |fx, fi| { + const twin = cells[twin_op][fi].min_us; + const alone = cells[alone_op][fi].min_us; + if (twin == 0 or alone == 0) continue; + if (@as(f64, @floatFromInt(twin)) > ratio * @as(f64, @floatFromInt(alone))) { + std.debug.print("perf gate: edit-twin on {s} took {d} us at best, over {d:.1}x edit-char's {d} us\n", .{ fx.name, twin, ratio, alone }); + failed = true; + } + } if (failed) return error.PerformanceRegression; std.debug.print("perf gate: every cell within {d:.1}x of the baseline\n", .{ratio}); } @@ -545,7 +562,13 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u core.active = id; const pane = core.panes[id].?; _ = try frame(core); - if (op == .edit_char) { + if (op == .edit_twin) { + if (!core.executeBuiltinLine(id, "Zerox")) return error.ZeroxRefused; + pump(core); + core.active = id; + _ = try frame(core); + } + if (op == .edit_char or op == .edit_twin) { core.update(.{ .key = .{ .cp = 'i', .text = "i" } }); pump(core); } @@ -572,7 +595,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u .key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }), .page_down => core.update(.{ .key = .{ .cp = pardes.Key.page_down } }), .wheel => core.update(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = wheel_col, .row = wheel_row } }), - .edit_char => core.update(.{ .key = .{ .cp = 'x', .text = "x" } }), + .edit_char, .edit_twin => core.update(.{ .key = .{ .cp = 'x', .text = "x" } }), .body_write => bodyWrite(core, pane.serial), .body_appends => bodyAppends(core, pane.serial), } @@ -591,11 +614,16 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u return error.PageDidNotScroll, .wheel => if (pane.scroll() <= before.scroll and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows) return error.WheelDidNotScroll, - .edit_char => { + .edit_char, .edit_twin => { if (pane.file.?.content.len != before.len + 1 or pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1) return error.CharacterWasNotInserted; const line = pardes.panes.File.sourceLine(pane, before.row); if (line[@intCast(before.col)] != 'x') return error.CharacterWasNotInserted; + if (op == .edit_twin) for (core.panes, 0..) |slot, other| { + const twin = slot orelse continue; + if (other == id or twin.file == null or twin.file.?.twin != pane.file.?.twin) continue; + if (twin.file.?.content.ptr != pane.file.?.content.ptr) return error.TwinMissedTheEdit; + } else if (pane.file.?.twin == 0) return error.NoTwin; }, } if (n >= warmup) samples[n - warmup] = dt / 1000; |
