#1009884 pulseaudio uses 10%--20% of CPU even when no sound is played

Package:
pulseaudio
Source:
pulseaudio
Description:
PulseAudio sound server
Submitter:
Maxime Devos
Date:
2022-04-19 21:15:04 UTC
Severity:
normal
#1009884#5
Date:
2022-04-19 21:04:28 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

Some time ago (I guess a month?), I noticed the fans didn't stop spinning even
when I'm not doing anything on the computer.  Looking at the output of
gnome-system-monitor, it appears that pulseaudio is using 17% of one CPU.
(It's only using a single CPU, according to the graphs).
The other CPUs are at 0%.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

To investigate a bit, I ran strace (from htop) on pulseaudio.
I noticed it does:

[start of output]
strace: Process 3615 attached
ppoll([{fd=4, events=POLLIN}, {fd=45, events=POLLIN}, {fd=49, events=POLLIN}, {fd=44, events=POLLIN}, {fd=46, events=POLLIN}, {fd=21, events=POLLIN}, {fd=29, events=POLLIN}, {fd=34, events=POLLIN}, {fd=37, events=POLLIN}, {fd=41, events=POLLIN}, {fd=38, events=POLLIN}, {fd=9, events=POLLIN}, {fd=35, events=POLLIN}, {fd=33, events=POLLIN}, {fd=32, events=POLLIN}, {fd=16, events=P
OLLIN}, {fd=31, events=POLLIN}, {fd=3, events=POLLIN}, {fd=30, events=POLLIN|POLLERR|POLLHUP}, {fd=30, events=0}, {fd=24, events=POLLIN}, {fd=27, events=POLLIN}, {fd=17, events=POLLIN}, {fd=20, events=POLLIN}, {fd=15, events=POLLIN|POLLERR|POLLHUP}, {fd=15, events=0}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=7, events=POLLIN}], 29, NULL, NULL, 8) = 1 ([{fd=20, revents
=POLLIN}])
read(20, "\1\0\0\0\0\0\0\0", 8)         = 8
write(5, "W", 1)                        = 1
read(4, "W", 10)                        = 1
write(40, "\1\0\0\0\0\0\0\0", 8)        = 8
read(4, 0x7ffddf14e70e, 10)             = -1 EAGAIN (Hulpbron is tijdelijk onbeschikbaar)
ppoll([{fd=4, events=POLLIN}, {fd=45, events=POLLIN}, {fd=49, events=POLLIN}, {fd=44, events=POLLIN}, {fd=46, events=POLLIN}, {fd=21, events=POLLIN}, {fd=29, events=POLLIN}, {fd=34, events=POLLIN}, {fd=37, events=POLLIN}, {fd=41, events=POLLIN}, {fd=38, events=POLLIN}, {fd=9, events=POLLIN}, {fd=35, events=POLLIN}, {fd=33, events=POLLIN}, {fd=32, events=POLLIN}, {fd=16, events=P
OLLIN}, {fd=31, events=POLLIN}, {fd=3, events=POLLIN}, {fd=30, events=POLLIN|POLLERR|POLLHUP}, {fd=30, events=0}, {fd=24, events=POLLIN}, {fd=27, events=POLLIN}, {fd=17, events=POLLIN}, {fd=20, events=POLLIN}, {fd=15, events=POLLIN|POLLERR|POLLHUP}, {fd=15, events=0}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=7, events=POLLIN}], 29, NULL, NULL, 8) = 1 ([{fd=29, revents
=POLLIN}])
read(29, "\1\0\0\0\0\0\0\0", 8)         = 8
write(18, "\1\0\0\0\0\0\0\0", 8)        = 8
read(4, 0x7ffddf14e70e, 10)             = -1 EAGAIN (Hulpbron is tijdelijk onbeschikbaar)
ppoll([{fd=4, events=POLLIN}, {fd=45, events=POLLIN}, {fd=49, events=POLLIN}, {fd=44, events=POLLIN}, {fd=46, events=POLLIN}, {fd=21, events=POLLIN}, {fd=29, events=POLLIN}, {fd=34, events=POLLIN}, {fd=37, events=POLLIN}, {fd=41, events=POLLIN}, {fd=38, events=POLLIN}, {fd=9, events=POLLIN}, {fd=35, events=POLLIN}, {fd=33, events=POLLIN}, {fd=32, events=POLLIN}, {fd=16, events=P
OLLIN}, {fd=31, events=POLLIN}, {fd=3, events=POLLIN}, {fd=30, events=POLLIN|POLLERR|POLLHUP}, {fd=30, events=0}, {fd=24, events=POLLIN}, {fd=27, events=POLLIN}, {fd=17, events=POLLIN}, {fd=20, events=POLLIN}, {fd=15, events=POLLIN|POLLERR|POLLHUP}, {fd=15, events=0}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=7, events=POLLIN}], 29, NULL, NULL, 8) = 1 ([{fd=20, revents
=POLLIN}])
read(20, "\1\0\0\0\0\0\0\0", 8)         = 8
write(5, "W", 1)                        = 1
read(4, "W", 10)                        = 1
write(40, "\1\0\0\0\0\0\0\0", 8)        = 8
read(4, 0x7ffddf14e70e, 10)             = -1 EAGAIN (Hulpbron is tijdelijk onbeschikbaar)
ppoll([{fd=4, events=POLLIN}, {fd=45, events=POLLIN}, {fd=49, events=POLLIN}, {fd=44, events=POLLIN}, {fd=46, events=POLLIN}, {fd=21, events=POLLIN}, {fd=29, events=POLLIN}, {fd=34, events=POLLIN}, {fd=37, events=POLLIN}, {fd=41, events=POLLIN}, {fd=38, events=POLLIN}, {fd=9, events=POLLIN}, {fd=35, events=POLLIN}, {fd=33, events=POLLIN}, {fd=32, events=POLLIN}, {fd=16, events=P
OLLIN}, {fd=31, events=POLLIN}, {fd=3, events=POLLIN}, {fd=30, events=POLLIN|POLLERR|POLLHUP}, {fd=30, events=0}, {fd=24, events=POLLIN}, {fd=27, events=POLLIN}, {fd=17, events=POLLIN}, {fd=20, events=POLLIN}, {fd=15, events=POLLIN|POLLERR|POLLHUP}, {fd=15, events=0}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=7, events=POLLIN}], 29, NULL, NULL, 8) = 1 ([{fd=20, revents
=POLLIN}])
read(20, "\1\0\0\0\0\0\0\0", 8)         = 8
write(5, "W", 1)                        = 1
read(4, "W", 10)                        = 1
write(40, "\1\0\0\0\0\0\0\0", 8)        = 8
read(4, 0x7ffddf14e70e, 10)             = -1 EAGAIN (Hulpbron is tijdelijk onbeschikbaar)
ppoll([{fd=4, events=POLLIN}, {fd=45, events=POLLIN}, {fd=49, events=POLLIN}, {fd=44, events=POLLIN}, {fd=46, events=POLLIN}, {fd=21, events=POLLIN}, {fd=29, events=POLLIN}, {fd=34, events=POLLIN}, {fd=37, events=POLLIN}, {fd=41, events=POLLIN}, {fd=38, events=POLLIN}, {fd=9, events=POLLIN}, {fd=35, events=POLLIN}, {fd=33, events=POLLIN}, {fd=32, events=POLLIN}, {fd=16, events=P
OLLIN}, {fd=31, events=POLLIN}, {fd=3, events=POLLIN}, {fd=30, events=POLLIN|POLLERR|POLLHUP}, {fd=30, events=0}, {fd=24, events=POLLIN}, {fd=27, events=POLLIN}, {fd=17, events=POLLIN}, {fd=20, events=POLLIN}, {fd=15, events=POLLIN|POLLERR|POLLHUP}, {fd=15, events=0}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=7, events=POLLIN}], 29, NULL, NULL, 8) = 1 ([{fd=29, revents
=POLLIN}])
[end of output]

   * What was the outcome of this action?

Looks like it's calling 'ppoll', which directly returns because one
of the fds is readable or such, but then pulseaudio doesn't actually
read/write to/from those fds, causing the next ppoll to return directly
again?

   * What outcome did you expect instead?

Approx 0% CPU utilisation by pulseaudio when not playing any sound, like in the past.

Feel free to suggest your own tests.  FWIW, Guix is installed on top of Debian.