Replace idle network poller with event-driven dispatcher

A/B measure and reject additional VM/sysctl/mount tweaks that did not improve idle without trade-offs. Remove sxmo_networkmonitor's long-lived nmcli device monitor, replace it with NetworkManager dispatcher hooks that run Sxmo network/statusbar hooks as the X session user, disable the superd unit in both start hooks, guard it in check-rebuild.sh, update docs, rebuild the image, and verify live Wi-Fi reconnect and idle context switches.
This commit is contained in:
Luxferre committed 2026-11-08 09:28:13 +02:00
1 parent 3543556735
commit 608a8ac71b
11 files changed
+236 -7

No files matched your search

+92
View File
@@ -1038,3 +1038,95 @@ The AP and userspace are already close to their idle floor. Further 24 h
battery life has to come from modem/Wi-Fi RF policy, DDR self-refresh, or a
battery-powered measurement campaign; another kernel config trim or full
module tree rebuild is not justified.
---
## 18. No-tradeoff idle headroom: A/B sweep and event-driven process cleanup
This section answers a narrower question than section 17: what can still be
saved at idle **without** delaying UI wakeup, calls/SMS, Wi-Fi, or network
state changes? All measurements below were 45-60 s screen-off windows on the
same USB-charged phone, so they are wakeup/IRQ/context-switch counts rather
than discharge mA. `vm.compaction_proactiveness=0` from section 17 stayed
active throughout.
### 18.1 Kernel/VFS candidates that were measured and rejected
| Candidate | Baseline | Candidate result | Decision |
| --- | --- | --- | --- |
| `vm.stat_interval=120` (from 30) | 96.85% CPU idle, 30.07 timer IRQs/s | 96.10% idle, 36.38 timer IRQs/s, `mmc0` 0.89/s | Rejected; worse or noise |
| `vm.vfs_cache_pressure=50` (from 150) | 96.85% idle | 94.34% idle, 47.38 timer IRQs/s | Rejected |
| `vm.swappiness=100` (from 180) | 96.85% idle, `mmc0` 0.21/s | 96.47% idle, `mmc0` 1.69/s | Rejected |
| `kernel.sched_autogroup_enabled=0` | 96.85% idle | 95.46% idle, 37.50 timer IRQs/s | Rejected |
| `noatime` rootfs remount | first run 96.85% -> 97.38% idle | confirmation run 97.49% -> 95.90% idle | Rejected; contradictory A/B |
`kernel.timer_migration` was already `1`. `vm.page-cluster=0`,
`vm.dirty_writeback_centisecs=6000`, `vm.dirty_expire_centisecs=6000`,
`kernel.nmi_watchdog=0`, `workqueue.power_efficient=Y` and the SPI/GPU/CPU
runtime-PM settings from earlier sections were already active. Raising the
dirty writeback interval or adding `commit=` would risk data loss on a sudden
power cut, so neither was shipped. All rejected sysctls and `relatime` were
restored on the live phone.
### 18.2 Process management: remove the `nmcli device monitor` poller
`sxmo_networkmonitor.sh` kept a long-lived `nmcli device monitor` plus two
shell wrappers alive to translate NetworkManager device states into Sxmo
network hooks and status bar updates. It accounted for roughly 0.08-0.13
context switches/s and duplicated the dispatcher path already used for DPM
and time sync.
It is replaced by:
- `etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh`, which
reacts to `up`, `down`, `pre-up`, `pre-down`, VPN equivalents, and
connectivity/DHCP/DNS changes, then double-forks so NetworkManager never
waits for shell hooks.
- `usr/bin/bananarchy-network-event.sh`, re-executed as the X session user
via `su`, which resolves the device type and calls the same
`sxmo_hook_network_{up,down,pre_up,pre_down}.sh` and
`sxmo_hook_statusbar.sh network` hooks. Running as the user keeps
`sxmo_status` files, the root status name and the status bar cache
user-owned.
- Both `sxmo_hook_start.sh` copies now run
`superctl disable sxmo_networkmonitor` instead of starting the poller;
`scripts/check-rebuild.sh` guards this.
This does not stop NetworkManager, wpa_supplicant, dnsmasq, ModemManager,
rmtfs, q6voiced, the DSDS helper, chronyd, dunst, or any preloaded DWM plugin.
Incoming network events still wake the same hooks immediately; only the idle
poller and its two shell wrappers disappear. Live verification after a Wi-Fi
disconnect/reconnect logged `09:22:55 up wlan0 wifi` from a temporary user
`sxmo_hook_network_up.sh`, with `wlan0` back on `OffOurStreets_`,
`sxmo_networkmonitor` stopped, `network_monitor_device` gone and no
`nmcli device monitor` process. A 60 s screen-off window after the change
measured 97.78% CPU idle with no `nmcli device monitor` in the top context
switchers (it had been ~0.08-0.13/s before).
### 18.3 Still available, but deliberately not shipped
- **Longer `statusbar_periodics` interval**: 300 s could become 600 s because
dmenu and unlock now refresh the clock, but an on-screen idle clock could
then be up to 10 minutes stale. Not shipped.
- **Longer `dsds-daemon` / `sxmo_modemmonitor.sh` / Wi-Fi scan intervals**:
these would delay modem or roaming state changes. Not shipped.
- **Consolidating `sxmo_soundmonitor.sh` / `sxmo_modemmonitor.sh` shell
pipelines**: possible, but they are event-driven (`evtest`,
`pactl subscribe`, `dbus-monitor`) and rewriting them risks audio/call
routing regressions for sub-0.1/s savings. Not shipped.
- **Wi-Fi listen interval >5, `MODEM_DRX_MODE=6-9`, `DSDS_SECONDARY_MODE=eco`**:
these trade inbound latency or SIM2 reachability for RF saving, so they
stay opt-in via `/etc/bananarchy-power-policy.conf`.
- **Serial console removal, `commit=60`, ABI-breaking kernel configs, full
module tree rebuild**: rejected for the reasons in sections 14-17.
### 18.4 Verdict
After sections 17 and 18, the remaining no-tradeoff AP/userspace headroom is
very small: the kernel is already ~98-99% idle, the 26 preloaded plugins and
Xorg are asleep when dark, runtime PM has collapsed the GPU/SDHCI/SPI/DMA
domains, and the remaining periodic work is either event-driven or spaced
300-1800 s apart. Further meaningful 24 h gains still require radio firmware
policy, DDR self-refresh via lk2nd PSCI `SYSTEM_SUSPEND`, or a real
battery-powered discharge measurement; they cannot come from more idle
timer/sysctl trimming without hurting latency or connectivity.