Skip to content

omamobile-shell 0.2.137: omamobile-sleepd checks a lasting refusal every 30 s, not every 2 s - #915

Open
W4HO-ham wants to merge 1 commit into
derekross:mainfrom
W4HO-ham:shell-sleepd-blocked-poll
Open

W4HO-ham wants to merge 1 commit into
derekross:mainfrom
W4HO-ham:shell-sleepd-blocked-poll

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

With the screen off behind the lock, omamobile-sleepd runs its full checks every 2 s: the toggle (omarchy-toggle-enabled), the screen (omarchy-hw-display, then Hyprland), the lock's state from the shell (omarchy-shell lock status, which goes through timeout and socat to the shell), SSH (ss), logind's inhibitors (busctl, jq) and the sinks (pactl). That is about 20 processes a time, and the shell answers every lock question. Where sleep is refused for a long time, that never stops. On a Pixel 9a the modem's boot unit holds a sleep inhibitor for the whole boot, so with the modem up it runs all day in a pocket.

Measured on my palmtop (a Pixel 9a, daily kernel, modem up, screen off, cgroup cpu.stat over a minute):

before after
omamobile-sleepd.service 4.9 s 0.72 s
the Hyprland session (the shell answering) 6.8 s 3.0 s
everything 25.3 s 14.7 s

Before, 1,573 processes were started in 30 s, mostly by the daemon.

The change: once a check finds sleep refused, the next full check comes OMAMOBILE_SLEEP_RECHECK seconds (30) later. The 2 s polls in between read the backlight's bl_power with bash's own read and start no process. A lit screen there, the power key (USR1) or a resume (USR2) brings the full check at once, so a screen turned on and off again starts the after-off wait again as before. A released inhibitor is seen within 30 s. Where no panel can be read (omarchy-hw-display gives nothing, or bl_power can't be read or reads 0), every poll is a full one, as now; that includes a screen that only Hyprland reports off.

Tests: test/sleepd.sh counts the shell's lock questions over 330 s with an inhibitor held: at most 40 allowed, 315 without the change. It also checks that an inhibitor released between checks lets it sleep within 30 s, that a screen lit and dark again between checks is seen (the refusal is logged again after the new wait), and that with no panel known every poll is a full one. The package's test/all, tests/all and tools/pr-check origin/main pass.

This is the 9a's case for the auto-sleep default in #912: with the modem up it never sleeps, so the daemon's polling is what the default costs there.

…ery 30 s, not every 2 s

With the screen off behind the lock, omamobile-sleepd ran its full checks every 2 s: the toggle, the screen through omarchy-hw-display and Hyprland, the lock's state from the shell (omarchy-shell, socat), SSH, logind's inhibitors and the sinks, about 20 processes each time, and the shell answered every lock question. On a Pixel 9a whose modem holds its sleep inhibitor for the whole boot that never ends: in a minute with the screen off the daemon used 4.9 s of CPU, 52 processes a second were started, and the system as a whole used 25 s. Now, once a check finds sleep refused, the next full check comes OMAMOBILE_SLEEP_RECHECK seconds (30) later; the 2 s polls in between read the backlight with no process started, and a lit screen, the power key or a resume brings the full check at once. A released inhibitor is seen within 30 s. With no panel to read, every poll is a full one, as before. On the palmtop, screen off, modem up: the daemon used 0.72 s in a minute, and the system 14.7 s. test/sleepd.sh counts the shell's lock questions over 330 s with an inhibitor held (at most 40; 315 before the change), and checks a release, a lit screen between checks and the no-panel case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant