a73x

35311690

Input-latency bench: cold child is cat > /dev/null

a73x   2026-04-18 06:42

Commit message
Input-latency bench: cold child is cat > /dev/null

Switch from sleep infinity to cat > /dev/null for the cold scenario.
Same kernel-echo behavior, but drains the PTY slave's input buffer
so samples can scale arbitrarily without buffer-fill risk.

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

docs/superpowers/specs/2026-04-18-input-latency-bench-design.md
Old New
@@ -23,7 +23,7 @@ New env var `WAYSTTY_INPUT_BENCH={cold|hot|both}` activates input-bench mode.
23 When active, waystty: 23 When active, waystty:
24 24
25 1. Spawns a minimal PTY child instead of `$SHELL`: 25 1. Spawns a minimal PTY child instead of `$SHELL`:
26 - `cold` → `sleep infinity`. Kernel PTY line discipline echoes each byte (ECHO flag on the slave); no reader needed. This removes `cat`'s canonical-mode buffering as a confound. 26 - `cold` → `cat > /dev/null`. Reads and discards stdin so the PTY slave's input buffer stays drained; kernel PTY line discipline echoes each byte (ECHO flag on the slave). Cat's canonical-mode buffering is irrelevant — we measure kernel echo, not cat's reads.
27 - `hot` → `sh -c 'yes "spam spam spam spam spam"'`. Continuous output contends with sentinel echo bytes on the PTY. 27 - `hot` → `sh -c 'yes "spam spam spam spam spam"'`. Continuous output contends with sentinel echo bytes on the PTY.
28 - `both` → runs cold, dumps stats, restarts child, runs hot. 28 - `both` → runs cold, dumps stats, restarts child, runs hot.
29 2. Disables real Wayland keyboard input (nothing is pushed to `keyboard.event_queue` from `src/wayland.zig`). Protects measurements from ambient user input or stuck modifier state. 29 2. Disables real Wayland keyboard input (nothing is pushed to `keyboard.event_queue` from `src/wayland.zig`). Protects measurements from ambient user input or stuck modifier state.
@@ -142,4 +142,4 @@ Mirrors the existing `bench` / `profile` targets: `OPT` defaults to `ReleaseFast
142 142
143 - **`wp_presentation_time` binding is non-trivial.** Neither the global nor the feedback callbacks exist in the repo. Budget real time for this, including the WSI-commit coordination (feedback request must precede `vkQueuePresentKHR`). 143 - **`wp_presentation_time` binding is non-trivial.** Neither the global nor the feedback callbacks exist in the repo. Budget real time for this, including the WSI-commit coordination (feedback request must precede `vkQueuePresentKHR`).
144 - **Mesa Wayland WSI internals.** Confirm empirically that `wp_presentation.feedback(surface)` called immediately before `vkQueuePresentKHR` attaches to the driver's commit. If not, we may need `VK_KHR_present_wait` or a different coordination strategy. 144 - **Mesa Wayland WSI internals.** Confirm empirically that `wp_presentation.feedback(surface)` called immediately before `vkQueuePresentKHR` attaches to the driver's commit. If not, we may need `VK_KHR_present_wait` or a different coordination strategy.
145 - **`sleep infinity` tty state.** Confirm kernel echoes bytes on a PTY whose slave-side reader is `sleep` (which doesn't open the tty in any special mode). If echo is off, `stty echo` on the slave fd before exec resolves it. 145 - **PTY termios state.** Confirm the default termios on the spawned child's slave fd has `ECHO` set so kernel echo works without an explicit `stty echo`. If not, call `tcsetattr` on the slave before exec.