summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-06 13:50:54 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commita43dc216f03c0bfed51ca539d027a90adc689ac8 (patch)
treeeb9be20342c4af9773100f3fa0082a4ad30b2c26 /src/pardes.zig
parentde4def3548a6729b0dfd2120495a61beef8c8c2c (diff)
downloadpardes-a43dc216f03c0bfed51ca539d027a90adc689ac8.tar.gz
pardes-a43dc216f03c0bfed51ca539d027a90adc689ac8.zip
tty: coalesce queued input events into one frame; tracy zones behind -Dtracy
The tty shell rendered (core.render + full vaxis repaint + tree-sitter re-highlight of the visible window) after EVERY event, so a wheel flick over a highlighted file was 150 re-parses and 150 terminal repaints; the gui shell drains the SDL queue before drawing and never had the issue. Now the tty loop applies every queued input event, then renders once (batch cap 64; pty output keeps a frame per chunk so progress paints and transient-state waits behave exactly as before). Measured with tracy on a 2400-line .zig scroll script: 150 highlightFileRange calls at 1.85ms mean -> 4; render pipeline total 730ms -> 64ms; 364 frames -> 39. Snap suite 18/18. Tracy: -Dtracy=<path-to-tracy-checkout> compiles TracyClient.cpp into the binary and turns src/tracy.zig zones live (default off, all no-ops). Sampling, callstacks, system tracing and the crash handler are disabled: tracy's symbol worker SIGSEGVs on this binary's debug info and its crash handler then parks every thread before the first frame. Capture: tracy-capture -o t.tracy; export: tracy-csvexport t.tracy.
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index c4893b25..63943c04 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -14,6 +14,7 @@ const uucode = @import("uucode");
const modal = @import("modal.zig");
const look = @import("look.zig");
const syntax = @import("syntax.zig");
+const tracy = @import("tracy.zig");
pub const image = @import("image.zig");
pub const dump = @import("dump.zig");
@@ -3077,6 +3078,8 @@ pub const Pardes = struct {
/// re-highlight the visible window of any file whose syntax went stale
/// (edit, scroll, load) — visible-range-first so big files stay snappy
fn refreshDirtyHighlights(p: *Pardes) void {
+ const tz = tracy.zone(@src(), "refreshDirtyHighlights");
+ defer tz.end();
for (p.panes) |slot| {
const pane = slot orelse continue;
if (pane.file == null) continue;
@@ -3226,6 +3229,8 @@ pub const Pardes = struct {
}
fn renderPane(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, active: bool) !void {
+ const tz = tracy.zone(@src(), "renderPane");
+ defer tz.end();
if (r.w <= GUTTER or r.h == 0) return;
const s = &p.surface;
const th = p.theme();
@@ -3278,7 +3283,9 @@ pub const Pardes = struct {
.fg = if (th.fg) |c| .{ .rgb = c } else .default,
.bg = if (th.bg) |c| .{ .rgb = c } else .default,
};
+ const tz_body = tracy.zone(@src(), "bodyText");
const body = try p.bodyText(arena, pane);
+ tz_body.end();
var it = std.mem.splitScalar(u8, body, '\n');
var i: u16 = 0;
while (it.next()) |line| : (i += 1) {
@@ -3303,6 +3310,8 @@ pub const Pardes = struct {
// tree-sitter style byte; content starts after the lineno gutter
if (p.colors_on) if (pane.file) |*f| {
if (f.highlights.len > 0) {
+ const tz_recolor = tracy.zone(@src(), "synRecolor");
+ defer tz_recolor.end();
var flines = std.mem.splitScalar(u8, f.content, '\n');
var skip: usize = 0;
while (skip < f.scroll) : (skip += 1) {