Repository navigation
perf(network): poll Wi-Fi status only while it can be seen - #244
Merged
dianjixz merged 1 commit intoNov 13, 2026
Merged
Conversation
- The status worker started two nmcli processes every 3 s for the launcher's lifetime, also while the screen was locked or another app owned the display. Each round costs ~0.2 s of CPU on the device, plus work in NetworkManager and the system bus. - It now refreshes every 3 s only while the launcher is in the foreground (LVGL_RUN_FLAGE == 1) and the backlight is on, and every 60 s otherwise. The worker still wakes every 3 s, so the status catches up within one interval after the screen comes back. - test_wifi_connection defines LVGL_RUN_FLAGE, as the keyboard tests do. - Measured on a CardputerZero (screen locked, on battery, on top of the system-sound idle fix): 212 -> 204 mA mean (median 203 -> 202 mA), context switches 818/s -> 516/s, no nmcli process seen in 30 one-second samples while locked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0135vUaG2FpgpGRJfB9LEPvZ
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.
Summary
The Wi-Fi status worker in
cp0_lvgl_network.cppstarts twonmcliprocesses every 3 s for the launcher's whole lifetime. It does this even when nobody can see the status: when the screen is locked, or when another app owns the display. With this PR it refreshes every 3 s only while the status is visible, and every 60 s otherwise.Change
poll_loop()still wakes every 3 s. It now callsupdate_status_cache()only when one of these holds:LVGL_RUN_FLAGE == 1) and/sys/class/backlight/backlight/brightnessis above 0;test_wifi_connection.cppdefinesLVGL_RUN_FLAGE, as the keyboard tests do, because the network source now reads it.Measurements
One polling round (
dev statusplusdev wifi list --rescan no) costs about 0.18 s of CPU on the device (user + sys, averaged over 5 rounds). NetworkManager and dbus-daemon also do work for every call.These were taken on a CardputerZero (0.6.105 plus the system-sound idle fix from the companion PR). Conditions: screen locked, on battery, 60 s of 2 s samples.
No
nmcliprocess showed up in 30 one-second samples while locked. The saving in current is small. Most of the effect is fewer CPU bursts and less work in NetworkManager and the system bus.Testing
sh ext_components/cp0_lvgl/tests/run_tests.shpasses.Note
I prepared this with AI assistance (Claude) and tested it on my own device. The backlight path is the same one
cp0_lvgl_settings.cppuses. If you would rather not read sysfs here, the poll could instead be driven by a "status visible" flag set from the UI side.