a73x

02224fad

Default bench + profile to ReleaseFast

a73x   2026-04-17 19:25

Previously bench ran Debug and profile ran ReleaseSafe. Both left
ghostty-vt with slow_runtime_safety=true, so ~94% of profile samples
landed in Page.verifyIntegrity and baselines reflected
safety-check overhead rather than shipping perf.

- Propagate target + optimize to the ghostty lazyDependency so its
  terminalOptions() drops slow_runtime_safety for non-Debug modes.
- Add OPT ?= ReleaseFast to the Makefile; bench / profile /
  bench-baseline / bench-check all honor it.
- Profile now uses --call-graph dwarf,16384 for readable unwinds
  without frame pointers.

Baseline regenerated (row_rebuild p99: 2952us -> 169us; total p99:
3224us -> 289us).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

diff --git a/Makefile b/Makefile
index c3fb2cc..f00a753 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
ZIG ?= zig
OPT ?= ReleaseFast
FLAMEGRAPH ?= inferno-flamegraph
STACKCOLLAPSE ?= inferno-collapse-perf

@@ -13,17 +14,15 @@ run: build
test:
	$(ZIG) build test

zig-out/bin/waystty: $(wildcard src/*.zig) $(wildcard src/tools/*.zig) $(wildcard shaders/*)
	$(ZIG) build

bench: zig-out/bin/waystty
bench:
	$(ZIG) build -Doptimize=$(OPT)
	WAYSTTY_BENCH=1 ./zig-out/bin/waystty 2>bench.log || true
	@echo "--- frame timing ---"
	@grep -A 12 "waystty frame timing" bench.log || echo "(no timing data found)"

profile:
	$(ZIG) build -Doptimize=ReleaseSafe
	WAYSTTY_BENCH=1 perf record -g -F 999 --no-inherit -o perf.data -- \
	$(ZIG) build -Doptimize=$(OPT)
	WAYSTTY_BENCH=1 perf record -g --call-graph dwarf,16384 -F 999 --no-inherit -o perf.data -- \
		./zig-out/bin/waystty 2>bench.log
	perf script -i perf.data \
		| $(STACKCOLLAPSE) \
@@ -39,10 +38,10 @@ golden-update:
	WAYSTTY_GOLDEN_UPDATE=1 $(ZIG) build test-render

bench-baseline:
	$(ZIG) build bench-baseline
	$(ZIG) build bench-baseline -Doptimize=$(OPT)

bench-check:
	$(ZIG) build bench-check
	$(ZIG) build bench-check -Doptimize=$(OPT)

clean:
	rm -rf zig-out .zig-cache perf.data bench.log flamegraph.svg tests/golden/output
diff --git a/build.zig b/build.zig
index de3b250..6a016fe 100644
--- a/build.zig
+++ b/build.zig
@@ -23,7 +23,10 @@ pub fn build(b: *std.Build) void {

    // Lazy-fetch the ghostty dependency. On the first invocation this
    // materializes the package; subsequent builds use the local cache.
    const ghostty_dep = b.lazyDependency("ghostty", .{});
    const ghostty_dep = b.lazyDependency("ghostty", .{
        .target = target,
        .optimize = optimize,
    });

    // zig-wayland scanner — generates protocol bindings at build time
    const wayland_dep = b.dependency("wayland", .{});
diff --git a/tests/bench/baseline.json b/tests/bench/baseline.json
index 2f5c98c..da89fb4 100644
--- a/tests/bench/baseline.json
+++ b/tests/bench/baseline.json
@@ -1,38 +1,38 @@
{
  "workload_sha": "a79a3b3449f44938e56bc64555a95cc5234c73a1dc4b05c4e8cc17aa0209d1df",
  "zig_version": "0.15.2",
  "waystty_sha": "321b22803777191c86a97ad7ce7edba9b90b6c9e",
  "frame_count": 65,
  "waystty_sha": "b7e080ca7f2ef8d5cd9d32eac59c264ffbdae99a",
  "frame_count": 202,
  "sections": {
    "snapshot": {
      "min": 6,
      "avg": 42,
      "p99": 216,
      "max": 735
      "min": 0,
      "avg": 1,
      "p99": 3,
      "max": 74
    },
    "row_rebuild": {
      "min": 121,
      "avg": 1450,
      "p99": 3344,
      "max": 3383
      "min": 10,
      "avg": 81,
      "p99": 193,
      "max": 233
    },
    "atlas_upload": {
      "min": 0,
      "avg": 4,
      "p99": 47,
      "max": 57
      "avg": 1,
      "p99": 19,
      "max": 24
    },
    "instance_upload": {
      "min": 3,
      "avg": 17,
      "p99": 75,
      "max": 83
      "min": 0,
      "avg": 1,
      "p99": 18,
      "max": 33
    },
    "gpu_submit": {
      "min": 22,
      "avg": 48,
      "p99": 99,
      "max": 106
      "min": 18,
      "avg": 52,
      "p99": 150,
      "max": 294
    }
  }
}
\ No newline at end of file