summaryrefslogtreecommitdiff
path: root/build.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 /build.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 'build.zig')
-rw-r--r--build.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 22dd7158..41f4c0ec 100644
--- a/build.zig
+++ b/build.zig
@@ -16,6 +16,7 @@ pub fn build(b: *std.Build) void {
const optimize = if (is_emscripten) .ReleaseSmall else requested_optimize;
const default_grammars: TreeSitterGrammars = if (is_emscripten) .minimal else .full;
const tree_sitter_grammars = b.option(TreeSitterGrammars, "tree-sitter", "tree-sitter grammar set: disabled, minimal, full") orelse default_grammars;
+ const tracy = b.option([]const u8, "tracy", "enable Tracy profiling; supply the path to a Tracy source checkout");
// the browser shell: zig object + emcc link + html, installed to zig-out/web
const web_step = b.step("web", "build the browser shell into zig-out/web (-Dplatform=web -Dtarget=wasm32-emscripten -Ddump=<dump.zon>)");
@@ -64,8 +65,32 @@ pub fn build(b: *std.Build) void {
opts.addOption(bool, "syntax_highlighting", tree_sitter_grammars != .disabled);
opts.addOption(bool, "syntax_minimal_grammars", tree_sitter_grammars != .disabled);
opts.addOption(bool, "syntax_full_grammars", tree_sitter_grammars == .full);
+ opts.addOption(bool, "enable_tracy", tracy != null);
root_mod.addOptions("pardes_config", opts);
+ // Tracy zones (src/tracy.zig): compile the client into the binary only when
+ // -Dtracy=<path> names a Tracy checkout; otherwise every zone is a no-op.
+ // Sampling/callstacks/system tracing stay off: tracy's symbol worker
+ // SIGSEGVs on this binary's debug info, and its crash handler then parks
+ // every thread — the app wedges before the first frame. Zones don't need
+ // any of it.
+ if (tracy) |tracy_path| {
+ root_mod.addIncludePath(.{ .cwd_relative = tracy_path });
+ root_mod.addCSourceFile(.{
+ .file = .{ .cwd_relative = b.pathJoin(&.{ tracy_path, "public", "TracyClient.cpp" }) },
+ .flags = &.{
+ "-DTRACY_ENABLE=1",
+ "-DTRACY_NO_SAMPLING",
+ "-DTRACY_NO_CALLSTACK",
+ "-DTRACY_NO_SYSTEM_TRACING",
+ "-DTRACY_NO_CRASH_HANDLER",
+ "-DTRACY_NO_CODE_TRANSFER",
+ "-fno-sanitize=undefined",
+ },
+ });
+ root_mod.link_libcpp = true;
+ }
+
// tree-sitter: the zig bindings + C runtime, one static lib per grammar,
// and each grammar's highlights.scm slurped at build time into the
// ts_queries options module (codegen consumed by comptime in syntax.zig).