pty: park the Linux PTY reader in poll(2) without spinning #421
No reviewers
Labels
No labels
priority/P0
priority/P1
priority/P2
release/v0.1.0
status/blocked
status/planned
type/bug
type/design
type/test-gap
type/tracker
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
natsukium/felis!421
Loading…
Reference in a new issue
No description provided.
Delete branch "pty/linux-reader-no-spin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On Linux the PTY reader stops spinning on
EAGAINand parks inpoll(2)right away. macOS keeps the 50 µs spin, which was sized for its ~1 KiB PTY lockstep. Linux queues ~68 KiB, so there the spin cost reader CPU and did not change the frame rate.Closes #399. The two parser costs from its profile are split out to #416 (SGR pen re-interning, 21% of the parse thread under DOOM-fire) and #417 (
Params::push_run, 10.7%).Refs #400. That issue proposed coalescing the ~13-byte reads on vtebench's scrolling rows. It is rejected, and
docs/explanation/implementation.mdrecords why: when output sits unread in the kernel, the producer's own write path gets slower. A bare drain pausing 20-50 µs between reads tookscrollingat 82x212 from ~160 to ~255 ms per sample (five interleaved pairs). A felis build that waited up to 50 µs while the parser was busy cut reader CPU by 93% but ran the harness's scrolling rows up to twice as slow.Measurements
Linux, i5-12400F, niri 60 Hz, NVIDIA through the pinned ICD (checked in the client's mapped libraries). Release builds of main
6f3931a1and of this change, run interleaved. The host is also the CI runner, so the 1-min load average is given with each figure.scrollingmedian, 93x212, 3 pairsscrolling_top_regionmedian, 3 pairscatsuite ascii / unicode / csi, 150 MBprofile_echo_latencyp50 / p99, 3 pairsThe spin never touched the scrolling rows' reader cost: those ~13-byte reads always find data waiting.
Review
pi (sol) round 1: PASS, with one non-blocking finding. It suggested dropping the doc comment on the Linux
READ_SPIN_WINDOWbecause the explanation doc already carries the rationale. I kept the comment: it is the why-not for someone who would otherwise bring the macOS spin back to Linux.