perf(cmux-tui-core): the input port's writer runs at user-interactive QoS once it carries a person's key (R-DAEMON-STATE S1.6d)

Merged
LA
2d ago
+60-2

Summary

R-DAEMON-STATE stage S1 step 6d (handoff/rewrites/R-DAEMON-STATE/DESIGN.md, section 2.6.1), from the review of the S1.7 default flip (#35413). Behind the stage switch CMUX_TUI_RDS_INPUT (only the input lane uses the port).

The defect. The person's keys cross their connection's three threads at user-interactive QoS (server/input_qos.rs, TYPING FIX 2 F7), then the terminal's input port writer, which was spawned at the default QoS and never raised itself. Under full CPU it waited for a CPU between the key's acceptance (daemon.send.written) and its write to the host. DESIGN 2.6.1 asks for the writer at user-interactive while it carries the person's input; it was listed after the #34544 review and not built. In the build 3b A/B (STATUS 11804), the lane-on keys over 4 ms waited in that hop (1.21-3.90 ms from daemon.send.written to the host's PTY write), and the lane-on tail was about 1 ms longer than the old path's.

The fix. The writer raises itself (input_qos::raise_this_thread, once per thread) when it takes a frame with no waiter that is not a viewer size: InputPort::enqueue, which only the person's keys use (InputReply::Accepted). Automation's writes (InputPort::write, a waiter) and viewer sizes do not raise it, so a port only automation writes to keeps the default QoS, as automation's connections do. A writer that exits idle starts again at the default. Off macOS this sets nothing.

Testing

Focused test (macOS only; QoS is a no-op elsewhere): the_input_ports_writer_runs_at_user_interactive_qos_once_it_carries_a_persons_key (surface/tests/hosted.rs). It checks that automation's write leaves the writer at the default QoS and that after a person's key the writer runs at user-interactive.

Compile: fleet job 4ae6ea4a97f3bd342dc4ac5e at the head 0c77eb0ac59: CmuxNext, app and cmux-tui passed (also bf8dbfe438eb0d68c30f6d19 at 3690c395049).

Observed / Not run

Changelog

none

Proof

No capture: a daemon thread priority, no UI.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the terminal input port's writer running at default QoS while carrying a person's keystrokes, so on macOS under full CPU a key no longer waits for a CPU between its acceptance and the write to the host.

  • The writer raises itself to user-interactive QoS (once per thread) when it takes a frame with no waiter that isn't a viewer size — the path only the person's keys use.
  • Automation's writes and viewer sizes don't raise it, so a port only automation writes to keeps the default QoS.
  • Off macOS this sets nothing, and a writer that exits idle starts again at the default.