Files
geminux/POWER-OPTIMIZATION.md
T

53 lines
4.0 KiB
Markdown

# Power optimization
Battery endurance and deep idle efficiency are first-class design requirements across the kernel, daemons, radios, display, audio, and storage stack in Geminux.
## Kernel-level optimizations
Configured in [kernel/configs/geminux-mt6797x.config](file:///home/lux/proj/geminux/kernel/configs/geminux-mt6797x.config) and built into `7.3.5-geminux`:
- **`CONFIG_HZ_100=y`**: 100 Hz tick rate cuts periodic timer interrupt overhead compared to 250 Hz / 1000 Hz kernels while remaining responsive for interactive X11 workloads.
- **`CONFIG_RCU_LAZY=y`**: Batches RCU callbacks during idle periods to extend CPU C-state residency.
- **`CONFIG_SUSPEND=y`**: Enables deep Suspend-to-RAM (`mem` / `deep`) triggered on Gemini PDA lid close (`SW_LID`) or power button press.
- **`CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y`**: Uses scheduler utilization feedback (`schedutil`) across the MT6797X tri-cluster (Cortex-A53 + Cortex-A72) topology instead of static `performance` governors.
- **`CONFIG_ZRAM_DEF_COMP_LZ4=y`** with `2 GiB` LZ4 `zram` swap (`etc/conf.d/zram-init`) and `vm.swappiness=100` (`etc/sysctl.d/99-geminux-power.conf`): avoids slow, power-hungry flash swap I/O on eMMC and pairs with `commit=60,noatime` mount options (`etc/fstab`).
## Zero-poll userspace daemons
All background system services avoid wake-up timers and polling loops:
- **`geminux-powerd`**: Sleeps indefinitely in `epoll_wait()` over `/dev/input/event*` (`SW_LID`, `KEY_POWER`), `KOBJECT_UEVENT` netlink (AC charger/HDMI hotplug), `/run/geminux/powerd.sock`, and an on-demand `timerfd`.
- **`geminux-statusd`**: Uses `signalfd` (`SIGUSR1`), `RTMGRP_LINK` netlink, `inotify`, and a minute-aligned `timerfd` so the DWM status bar wakes only on actual network/power/modem changes or minute boundaries with zero child shell forks.
- **`geminux-ccci-daemon` & `geminux-modem-ctl`**: Event-driven `epoll_wait()` over `/dev/ccci_*`, AT port, and netlink; enter completely idle sleep when no modem activity is pending.
- **`geminux-bt-obex` & `geminux-leds`**: Event-driven GLib/GDBus and `epoll_wait()` + `KOBJECT_UEVENT` control without periodic polling.
## Cluster gating and profiles
`geminux-power-ctl` (and `geminux-control`) switches between three profiles managed in [src/geminux-daemons/geminux-power-policy.c](file:///home/lux/proj/geminux/src/geminux-daemons/geminux-power-policy.c):
| Profile | Governor | A72 big cores (`cpu8..9`) | A53 max freq | Auto-suspend on battery |
| --- | --- | --- | --- | --- |
| `eco` | `schedutil` | Offline (`0`) | `1391 MHz` | `180 s` idle |
| `balanced` | `schedutil` | Online (`1`) | `1547 MHz` | `300 s` idle |
| `performance` | `schedutil` | Online (`1`) | `1846 MHz` | Disabled |
Closing the Gemini PDA clamshell (`SW_LID = 1`) suspends immediately to RAM (`mem`), unless inhibited by an active voice call (`inhibit add call`), an explicit inhibitor, or a connected external HDMI monitor (`SiI9024`).
## Audio, radios, and storage defaults
- **Audio**: PipeWire uses `default.clock.min-quantum = 1024` and `quantum = 2048` (`10-geminux-power.conf`); WirePlumber suspends idle ALSA and BlueZ nodes after `3` seconds (`50-geminux-suspend.conf`) so audio DSP clocks gate quickly.
- **Bluetooth**: `bluetooth` OpenRC service is disabled from default boot (`AutoEnable=false` in `etc/bluetooth/main.conf`); users toggle Bluetooth on demand via `geminux-net`.
- **Wi-Fi**: NetworkManager enforces `wifi.powersave = 3` (`10-geminux-power.conf`).
- **Storage**: `noatime,commit=60` in `etc/fstab` alongside `vm.dirty_writeback_centisecs=1500` reduces eMMC write amplification and wakes.
## Auditing on device
Run the bundled C11 audit utility at any time:
```sh
geminux-power-audit
geminux-power-audit --json
```
It prints the live power profile, battery capacity/voltage/current, online CPU count (including A72 cluster gating status), CPUfreq governor, ZRAM compression algorithm, and supported `/sys/power/mem_sleep` modes. Live idle current draw and multi-hour standby battery endurance benchmarks must be measured on physical Gemini PDA (x27) hardware after flashing.