Repository navigation
Conversation
The renderer main loop tried a nonblocking receive and slept 5 ms when nothing had arrived, so an idle Touch Bar woke the CPU about 200 times a second. It now blocks in poll() on the hardware socket and on a wake socket that the desktop-provider and overlay threads write to after publishing, with a timeout only while something is timed: a fade or a progress animation (the old 5 ms pacing) or the next hold repeat. t1-platform gets SeqPacketClient::wait_readable for this, backed by t1_seqpacket_wait_readable in C.
With a renderer connected the service woke every 10 ms to look for input, about 100 times a second. Digitizer, Fn and renderer readiness already end the wait, so it now waits up to the session check interval (50 ms), which is still often enough for the session check. Without a renderer it keeps the 10 ms probe of the listener.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With nothing to draw, the two Touch Bar daemons wake the CPU about 290
times a second. The renderer's main loop sleeps 5 ms between nonblocking
receives, and t1-touchbar-hw waits for input with a 10 ms timeout. On my
MacBookPro14,3 that was 1210 of the 1440 idle exits per second of the whole
machine.
The renderer now blocks in poll() on the hardware socket and on a wake
socket that the desktop provider and overlay threads write to after they
publish. It sets a timeout only while something is timed: a fade or
progress animation (at the old 5 ms pacing) or the next hold repeat. For
this t1-platform gets
SeqPacketClient::wait_readable, backed byt1_seqpacket_wait_readablein C.t1-touchbar-hw now waits up to 50 ms while a renderer is connected, the
session check interval. Digitizer, Fn and renderer readiness still end the
wait at once. Without a renderer it keeps the 10 ms probe of the listener.
With #70 applied, the Fn state under a keyboard grab is then read every
50 ms instead of every 10 ms.
Measured on a MacBookPro14,3 with CachyOS (kernel 7.3.6), idle, panel on:
both daemons running against both stopped with SIGSTOP, interleaved 30 s
windows, package power from RAPL and system power from the SMC (
PSTR).The 10 a second left in the renderer are the overlay watcher's 100 ms file
poll, which I did not touch.
Tested:
cargo fmt --check, clippy and the tests of t1-platform,t1-touchbar and t1-touchbar-hw, the t1-daemons C tests with and without
the sanitizers. With Rust 1.100 clippy also reports a deprecated
fetch_updateandassert_is_emptyin code this does not touch. On themachine: display and keyboard brightness, the hold repeat, Fn under keyd,
and the Touch ID overlay fading in and out.