summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/next-daemon.md10
-rw-r--r--src/terminal.zig18
2 files changed, 21 insertions, 7 deletions
diff --git a/docs/next-daemon.md b/docs/next-daemon.md
index f6400770..ce828b89 100644
--- a/docs/next-daemon.md
+++ b/docs/next-daemon.md
@@ -2171,9 +2171,13 @@ scripts are in `.scratch/daemon/remote/t2/`.
the opens 0.93 to 1.02; body-2m 1.02 to 1.26 (small's 1.26 alone); the
scrollback cells 0.93 to 1.05. The A/A read 0.79 to 1.46 (most within
0.9 to 1.1). Against base the keys read 1.11 to 1.20 and the
- scrollback renders 1.68 to 2.18: main's since base (this line is level
- with main), and base's harness is an older perf.zig, so that pair
- measures the harness too.
+ scrollback renders 1.68 to 2.18, but that pair was wrong: both of
+ this line's core benchmarks were built at the default `-Doptimize`
+ (their `--json` identity says `core_optimize` debug and
+ `terminal_optimize` safe; the driver alone is ReleaseFast) and base's
+ is ReleaseFast throughout. Built ReleaseFast, main's file gestures are
+ level with base, and a terminal's frame is faster than base's since
+ `terminal.cellAt` (the final gate's notes, at the end).
The gates, once at the end (Debug unless said):
- `zig build unit-test -Dplatform=tty` passes, its perf gate too;
diff --git a/src/terminal.zig b/src/terminal.zig
index 42268f0a..acff68f4 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -2313,7 +2313,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
crossed = true;
const upto = anchor.shell_len - @min(anchor.suffix, anchor.shell_len);
while (sb < upto) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
sb += dumpedBytes(row_pin, ci.cell);
gc = std.math.add(u16, gc, 1) catch break;
}
@@ -2324,7 +2324,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
var covered: usize = 0;
var style: ?pardes.CellStyle = null;
while (covered < want) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
if (style == null and ci.cell.wide != .spacer_tail and ci.cell.wide != .spacer_head)
style = cellStyle(p, ci, filtered, scnm);
covered += dumpedBytes(row_pin, ci.cell);
@@ -2333,7 +2333,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
// spin on a row that ends in one.
if (covered == 0 and gc >= pane.cols) break;
}
- while (pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } })) |t| {
+ while (cellAt(pages, row_pin, gc)) |t| {
if (t.cell.wide != .spacer_tail) break;
gc = std.math.add(u16, gc, 1) catch break;
}
@@ -2350,7 +2350,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
var tail: ?pardes.CellStyle = null;
if (anchor.whole() or anchor.suffix > 0) {
while (sc < tw) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
gc = std.math.add(u16, gc, 1) catch break;
if (ci.cell.wide == .spacer_tail) continue;
const cell = s.at(tx + sc, body_y + vr);
@@ -2371,6 +2371,16 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
}
}
+/// The cell at column `x` of the row `row` pins, as `pages.getCell` reads
+/// it, without walking from the viewport's top down to the row again: that
+/// walk, once a cell, was most of a terminal's paint (once getCell was no
+/// longer inlined, a frame of a 120x40 shell took 75 µs more).
+fn cellAt(pages: *const ghostty_vt.PageList, row: ghostty_vt.Pin, x: u16) ?ghostty_vt.PageList.Cell {
+ if (x >= pages.cols or x >= row.node.cols()) return null;
+ const rac = row.node.page().getRowAndCell(x, row.y);
+ return .{ .node = row.node, .row = rac.row, .cell = rac.cell, .row_idx = row.y, .col_idx = x };
+}
+
fn cellStyle(p: *Pardes, ci: ghostty_vt.PageList.Cell, filtered: ?*FilteredColors, scnm: bool) pardes.CellStyle {
const style = ci.style();
var cs: pardes.CellStyle = .{