snapd generating wakeup events, keeps CPU from being idle
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Triaged
|
Medium
|
Samuele Pedroni |
Bug Description
I was analysing the Eoan desktop image to see where wakeup events are being generated and spotted that snapd was causing quite a few wakeups over a 30 minute period. I used health-check [1] to monitor the snapd activity to see timer events activity:
sudo apt install health-check
sudo health-check -p snapd -f -r -d 1800
There seems to be a nanosleep() system call that is generating ~0.35 sleep/wakeups per second which is the main contributing factor to the overall 1.37 context switches per second. Snapd is not exactly idle on an "idle" system. There are also some epoll_pwait() system calls being called with a zero timeout, so these look like non-blocking epoll peeks which may be eating more CPU time by polling instead of blocking waits.
Can these sleep/wakeups and polling epolls be investigated to make snapd be more power friendly?
See attached log for more details.
References:
[1] https:/
Changed in snapd: | |
assignee: | nobody → Samuele Pedroni (pedronis) |
importance: | Undecided → Medium |
status: | New → Triaged |
I have been finding snapd wakes up at ~12Hz, putting it among the top 10 kernel tasks and processes consuming energy under PowerTOP on an idle GNOME desktop, only GNOME terminal open.
I have been seeing the same behaviour since snapd was mandated; given no housekeeping is expected, these wakeups can most likely be avoided. On Ubuntu 21.10 on a Dell XPS 15:
PowerTOP v2.11 Overview Idle stats Frequency stats Device stats Tunables WakeUp
The battery reports a discharge rate of 5.27 W
The power consumed was 111 J
The estimated remaining time is 15 hours, 0 minutes
Summary: 157.6 wakeups/second, 0.0 GPU ops/seconds, 0.0 VFS ops/sec and 2.2% CPU use
Power est. Usage Events/s Category Description gnome-shell snapd/snapd
...
49.6 mW 4.2 ms/s 4.7 Process [PID 1966] /usr/bin/
49.6 mW 194.8 µs/s 13.3 Process [PID 13] [rcu_sched]
42.4 mW 135.1 µs/s 11.5 kWork psi_avgs_work
42.2 mW 105.6 µs/s 11.5 Process [PID 888] /usr/lib/