Repository navigation
Conversation
[Medium impact] No new blocking issue was found. SummaryReduces repeated clamshell work while a laptop is docked.
No new findings were accepted. Earlier unnumbered threads remain review context and were not reposted. Reviews (7) · Last reviewed commit: "Skip clamshell poll syncs unless the lid..." · Reviewed by Greptile |
3b90b6c to
70dfc09
Compare
|
On the "failed corrections stop retrying" finding: fixed in 70dfc09. The fingerprint is now recorded only when sync_clamshell() {
(
local status=0
flock -n 9 || exit 0
omarchy-hyprland-monitor-clamshell || status=1
omarchy-system-lid-inhibit || status=1
exit "$status"
) 9>"$LOCK"
}With a clamshell stub that exits 1, the poll now runs one attempt per tick instead of one total: 3 attempts in a 6s window, versus 0 before the fix. With the stub succeeding, a lid flip and a monitor change still run exactly one sync and idle runs none. |
70dfc09 to
a1a432d
Compare
|
Second finding covered in a1a432d: a sync that found the lock taken was reported as done.
The poll retries every tick while the compositor stops answering, and a lid flip after it returns still lands (verified with a |
0749217 to
49a18cd
Compare
|
All three findings, on 49a18cd: Opened laptop screen stays off (P1) — the lid is in the fingerprint, which is what 70dfc09 added after that review (it ran against 8391aa0, the monitor-only version). The lid is read through Failed corrections stop retrying (P2) — fixed in a1a432d: the fingerprint is recorded only after Lid policy changes are ignored (P2) — valid and fixed in 49a18cd. The gate skipped |
The docked reconciliation poll ran a full sync every 2s even when nothing moved. Its only input with no event is the lid: monitors arrive on the socket, and the switch binds cover the lid only where Hyprland can read the switch. Compare the lid from the ACPI button file (a builtin read, no fork) and sync on a change, plus one a minute for what no comparison can see: the logind lid policy omarchy-system-lid-inhibit reads, and drift that leaves both the lid and the monitor list untouched. The lid is recorded only after a sync succeeds, so a correction that failed, or that found the lock taken by another sync, is retried on the next tick. sync_clamshell now reports a failure from either helper, and reports the lock as taken rather than done, which is what that retry reads. Measured on a docked laptop at idle: 5.4% -> 0.30% of one core, 49 to 21 jiffies per minute, with the sync still running on a lid or monitor change.
49a18cd to
df29182
Compare
|
df29182 replaces the fingerprint with a comparison of the one input that has no event. Monitors already arrive on the socket this watcher reads, so hashing their fields every 2s was work for a state the loop is told about anyway. The lid is the only clamshell input with no event on hardware whose switch Hyprland cannot read, and it is a builtin read of the ACPI button file with no fork. The minute backstop stays for the logind policy and for drift neither the lid nor the monitor list would show. The earlier revision, which hashed the lid plus six monitor fields, measured 0.80% of one core docked. This one measures 0.30%, with the same behaviour: one sync on a lid change, the retry chain on a monitor event, none at idle. I also measured two designs that go further, in separate worktrees on the same machine:
The |
What
The docked reconciliation poll in
omarchy-hyprland-monitor-watchruns a fullsync_clamshellevery 2s, forking a hyprctl + jq pass and clamshell children each tick, even when nothing moved.The only clamshell input with no event is the lid. Monitors arrive on the socket the watcher already reads, and the
switch:*:Lid Switchbinds cover the lid on hardware whose switch Hyprland can read. So the poll now compares the lid from the ACPI button file, which costs a builtinreadand no fork, and runs a sync on a change, plus one a minute for what no comparison can see:HandleLidSwitchDockedpolicyomarchy-system-lid-inhibitreadsOn a machine with no ACPI lid (Apple Silicon) it falls back to
omarchy-hw-laptop-closed, the same helper clamshell decides with.The lid is recorded only after a sync succeeds, so a correction that failed, or that found the lock taken by another sync, is retried on the next tick.
sync_clamshellnow reports a failure from either helper, and reports the lock as taken rather than done, which is what that retry reads.Measured
Docked laptop, idle, 70s window:
The cost of one tick, measured against the real binaries:
hyprctl monitors all -j | jq | cksumis 0.70 jiffies, the ACPI lid read is 0.00, the lid helper fork 0.18,sleep 20.10, and a full clamshell sync 8.0.Behaviour, against the watcher with stubbed
hyprctl, lid, clamshell and lock:Alternatives measured
Built and measured in separate worktrees, same harness, same machine:
read -t 2sync_poll_stateVerified on real hardware
Samsung Galaxy Book (Intel, Hyprland 0.57.0), docked to a DisplayPort monitor at 2560x1440@240, with the default lid binds removed so the poll is the only path that reconciles clamshell:
Suspend and resume, docked and undocked, and undocking with the lid shut were exercised on the same machine; the watcher and its poll kept their PIDs across a suspend, and the
monitorremovedhandler re-enabled the internal panel before logind suspended.Tests
bash test/shell.d/lid-inhibit-test.shpasses, including "the watcher keeps one inhibitor across hotplugs, retries and its poll".bash test/shell.d/monitor-modeless-test.shpasses.bash test/shell.d/lid-close-test.shpasses.bash -nclean.