From a43dc216f03c0bfed51ca539d027a90adc689ac8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 6 Jul 2026 13:50:54 -0300 Subject: 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= 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. --- src/syntax.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/syntax.zig') diff --git a/src/syntax.zig b/src/syntax.zig index a9914fd7..0d2fa291 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -4,6 +4,7 @@ //! compiles queries at startup; `full` adds ~23 languages lazily on first use. const std = @import("std"); const config = @import("pardes_config"); +const tracy = @import("tracy.zig"); pub const enabled = config.syntax_highlighting; const minimal_grammars = config.syntax_minimal_grammars; @@ -140,6 +141,8 @@ pub fn highlightFile(gpa: std.mem.Allocator, path: []const u8, content: []const /// One Syn byte per content byte in [start, end). Caller frees. pub fn highlightFileRange(gpa: std.mem.Allocator, path: []const u8, content: []const u8, start_byte_raw: usize, end_byte_raw: usize) ![]u8 { + const tz = tracy.zone(@src(), "highlightFileRange"); + defer tz.end(); if (!enabled) return &.{}; const ext = std.fs.path.extension(path); const selected = (forExt(ext) catch return &.{}) orelse return &.{}; -- cgit v1.3