The officially official Devuan Forum!

You are not logged in.

#1 2020-08-09 19:29:58

Copper36
Member
Registered: 2018-11-27
Posts: 55  

High CPU by PulseAudio

Hi,
A couple of days ago I noticed something was taking quite a lot of CPU load at rest (not sure when exactly it started though). It turned out that the task pulseaudio --start --log-target=syslog was continuously using 8-10% CPU. Right after reboot it was 0-1%, and now it's already 3-4%. No specific sound-related apps are running, just Firefox/Thunderbird and a file manager. On a different PC used for the same purposes this PulseAudio task is exactly 0% all the time.
I do not think I meddled with settings/tweaks at any time recently, only the official updates. I've looked online, but there seems to be a wide variety of pulseaudio problems that may cause such a behavior, and since I'm pretty sure I have not changed anything recently, I simply do not know where to start from. May I ask for some directions?
The system is a rather old all-Intel laptop with Realtek audio, Devuan ASCII 64bit.

Thank you.

Offline

#2 2020-08-09 20:03:59

larsH
Member
Registered: 2020-05-05
Posts: 184  

Re: High CPU by PulseAudio

Hi

Maybe try this https://dev1galaxy.org/viewtopic.php?id=3732 Howto disable pa see here https://dev1galaxy.org/viewtopic.php?id=3728 . And here do the opposite of what is suggested

Have a nice day
Lars H

Offline

#3 2020-08-10 15:00:48

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Thanks Lars,

Maybe I missed something, but for some reason I do not have any sound with ALSA alone. What I did was:
1. Turned off PulseAudio autostart.
2. Added volumeicon autostart.
3. ALSA settings: automute was on, so I turned it off. Sound card/input and output channels are correctly selected and non of them are muted.
As a result, still no sound with ALSA alone.

Thank you.

Offline

#4 2020-08-10 15:37:48

larsH
Member
Registered: 2020-05-05
Posts: 184  

Re: High CPU by PulseAudio

Hi

Do you have multiple soundcards ??. Take a look with "alsamixer" in a terminal. F6 will allow you to choose and set your default soundcard. You can also choose soundcard in volumicon by right clicking and choose preferences. Hopefully this is your problem. If not we have to look a littel deeper. But the simple things first ;-))

Have a nice day
Lars H

Offline

#5 2020-08-10 15:53:32

golinux
Administrator
Registered: 2016-11-25
Posts: 3,317  

Re: High CPU by PulseAudio

I need an .asoundrc config to sort the 2 sound devices on my board!

Online

#6 2020-08-11 17:09:29

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Thanks a lot Lars,

It turned out I needed to reboot, not just to log out.
However this is not quite what I expected, because though initially I do not see a pulseaudio --start --log-target=syslog task, it keeps re-appearing at the moment I start, for example, Clementine or Skype and consumes the same 1-4% CPU. So it looks to me that those apps either do require Pulseaudio (and initiate it on start) or one needs to clean the whole damn thing out completely to use ALSA alone.
Technically, it wouldn't be that bad, because Clementine alone results in 1% CPU used by PA. But the bigger issue is that even Firefox, which I must keep open all the time (due to my work Outlook mailbox) also initiates PA via AudioIPC Server: AudioCallbackDriver. Maybe if I turn off sound notifications it won't be activated...
So the bottom line is probably that you're too optimistic about using ALSA alone and too many common apps are hard-coded to use PA... sorry.

Any thoughts?

Thank you!

Offline

#7 2020-08-11 17:16:42

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: High CPU by PulseAudio

Copper36 wrote:

even Firefox, which I must keep open all the time (due to my work Outlook mailbox) also initiates PA via AudioIPC Server: AudioCallbackDriver.

The Devuan firefox-esr package does not need PulseAudio at all. I have yet to find an application from the repositories that actually needs PA.


Brianna Ghey — Rest In Power

Offline

#8 2020-08-11 17:29:44

larsH
Member
Registered: 2020-05-05
Posts: 184  

Re: High CPU by PulseAudio

Hi

It looks like you get sound working ;-)

I am a professional musician myself using my setup for everything. And I have removed all of pulseaudio. Using firefox, vlc, mpv, audacity, musescore with just alsa. And for professional work I use jack as audioserver.

Make sure your /etc/pulse/client.conf.d/00-disable-autospawn.conf looks like this:

# On linux systems, disable autospawn by default
# If you are not using systemd, comment out this line
autospawn=no

Then you should be safe that pulseaudio is not working. If you find any problems then try uninstall and purge pulseaudio with apt purge pulseaudio. Then apt will also remove pulseaudio configuration files (that might be your problem)

Have a nice day
Lars H

Offline

#9 2020-08-11 17:32:13

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Head_on_a_Stick wrote:

The Devuan firefox-esr package does not need PulseAudio at all. I have yet to find an application from the repositories that actually needs PA.

Do you mean Devuan repos? Skype is definitely from MS repo and I do not remember if Clementine 1.31 I have comes from Devuan repos or not. The facts are that if I do not start them, I do not see any traces of PA in a task manager, but as soon as they are active, PA re-appears and consumes quite a lot (for a laptop at least). And these two are pretty basic and widely used apps I guess.
The FF I have is from the Devuan repo, so I'll check this out too.

Thank you.

Last edited by Copper36 (2020-08-11 17:33:05)

Offline

#10 2020-08-11 17:40:33

larsH
Member
Registered: 2020-05-05
Posts: 184  

Re: High CPU by PulseAudio

Hi again

We can help the best if you are using devuan repos only. If you install programs from other places they might very well be configured with both systemd, pulseaudio, libraryversions and other things that are not compatible with devuan. So be careful when you do that. If things work to your satisfaction then fine (using a bit of cpu sounds like an acceptable compromise). But take care when upgrading. You might break your system in the process.

Have a nice day
Lars H

Last edited by larsH (2020-08-11 17:41:34)

Offline

#11 2020-08-11 17:47:17

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: High CPU by PulseAudio

Copper36 wrote:

Skype is definitely from MS repo and I do not remember if Clementine 1.31 I have comes from Devuan repos or not. The facts are that if I do not start them, I do not see any traces of PA in a task manager, but as soon as they are active, PA re-appears

Just because they start PA does not necessarily mean that they need PA — firefox-esr will also auto-start PA but it will still produce sound if PA is not installed.

But I've never used Skype so I have no idea if it will work without PA, why don't you try it and report back?


Brianna Ghey — Rest In Power

Offline

#12 2020-08-11 18:08:21

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

larsH wrote:

Make sure your /etc/pulse/client.conf.d/00-disable-autospawn.conf looks like this:

# On linux systems, disable autospawn by default
# If you are not using systemd, comment out this line
autospawn=no

I do not have exactly the same location of the config files, but when I replaced autospawn=yes with autospawn=no in /etc/pulse/client.conf nothing changed.
I'll try to purge PA completely, we'll see what happens.

Thank you.

Offline

#13 2020-08-11 18:20:40

golinux
Administrator
Registered: 2016-11-25
Posts: 3,317  

Re: High CPU by PulseAudio

Copper36 wrote:
larsH wrote:

Make sure your /etc/pulse/client.conf.d/00-disable-autospawn.conf looks like this:

# On linux systems, disable autospawn by default
# If you are not using systemd, comment out this line
autospawn=no

autospawn=no in /etc/pulse/client.conf nothing changed.

"Comment out" looks like this:
# autospawn=no

Online

#14 2020-08-11 18:24:39

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

golinux wrote:

"Comment out" looks like this:
# autospawn=no

Well, I thought it was binary - either on or off... looks like there is a third option :-)

Offline

#15 2020-08-11 18:29:33

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

So I've removed PA with all configs and + autoremoved unneeded packages. Clementine and Skype both work fine. I'll check everything else and if there are no problems, I'll repeat the same on my "production" laptop :-)

Thanks a lot!

BTW, what are those things PA can do that ALSA can't? I mean, for a common user like me? For example, if I'm listening to music and new mail comes with a sound notification, will that notification be heard on top of background music with/without PA?

Offline

#16 2020-08-11 19:12:47

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: High CPU by PulseAudio

Copper36 wrote:

what are those things PA can do that ALSA can't?

There are a few things like per-application volume levels (but almost every application that outputs sound has it's own volume control anyway), multiplexing (but this can be replicated in ALSA with the DMix plugin), sample rate conversion & equalisation (but it's best to use a dedicated DAC for the former and not use the latter at all) and networked audio (if all the machines on the network also have PA) but the most important advantage is plain convenience — pure ALSA tends to require command line or text file configuration whereas PA has some nice GUIs to handle most tasks.


Brianna Ghey — Rest In Power

Offline

#17 2020-08-11 19:31:08

larsH
Member
Registered: 2020-05-05
Posts: 184  

Re: High CPU by PulseAudio

Hi

And as professionel I am using jack for most of this when it really matters. It reduces latency together with alsa, which in that situation is the most important thing. I also think using pulseaudio is much simpler for the programmer, because he does not need to take care of a lot of small details. But on high end gear I can hear a difference between pulseadio and alsa because of the higher latency.

Have a nice day
Lars H

Offline

#18 2020-08-21 18:13:37

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Some updates on "living without PA":

1. With ALSA controls only, the sound is very quiet now. Only with Master/Speaker/PCM close to 100% it is kind of OK. Yes, it was much louder with PA (and Win7) and no, there were no sound distortions.

2. For some reason Clementine began to consume 10-12% CPU while playing any .mp3/.ogg file. It used to be about 3-4% and this is the number I see now using preinstalled QuodLibet or VLC. Clementine was installed from Devuan repos, all graphics/equalizer are turned off (as it was before, did not change anything).

So as usually happens, if smth is better, smth will definitely get worse :-)

Any ideas?

Thank you.

Offline

#19 2020-09-14 20:17:59

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Some updates (with a question).
As I've mentioned above, sound volume with ALSA alone became very low, so I tried to boost it somehow.
Fortunately, it is a relatively well-known issue and the most recommended solution is to add a pre-amplifier to ALSA. I used this tutorial:
https://alien.slackbook.org/blog/adding … nd-levels/
however whatever I tied I still could not see an additional "pre-amp" option in ALSA mixer.
Maybe the location/name of the .conf file should be different (Slackware vs Devuan)?

Thank you.

Offline

#20 2020-10-28 19:06:08

Copper36
Member
Registered: 2018-11-27
Posts: 55  

Re: High CPU by PulseAudio

Hi,

I hate leaving business unfinished and that's why I'm back:-). I've finally managed to figure out what caused my problems and would like to share it, hoping that  someone might find it useful.

First, I tried to completely get rid of PA. Can you live without PA? Yes. Will you like it? Maybe, but not so sure. After removing PA I still have sound (which is good), but faced a bunch of problems and restrictions, that included:
1. Very low max volume. I have a Windows system on the same laptop, so I could compare all 3: Win, PA and ALSA. ALSA had that low volume that in several cases I had to use headphones. I tried to fix it introducing an additional pre-amplifier via special script and it kind of worked - the sound became louder, but there appeared irregular sound distortions, that DID NOT depend on volume. So I had to disable the pre-amp.
2. A bunch of smaller things, that still might be very important. For example, you one needs PA in order to share sound in ZOOM.

Having all that, I decided to take a closer look at what exactly caused the high CPU consumption by PA. With re-installed PA I noticed that it starts taking up more and more CPU right after I use reader view in FF. PA Audio Mixer / Playback shows 3 more text to speech streams, which very likely were the culprits. Since I do not use this feature (text-to-speech), I removed a speech-dispatcher package (and its dependences) + orca-gnome just in case :-). And it looks like this made a trick. No additional streams, rather low CPU consumption by PA (though not a complete zero...). Technically, it seems it was possible to block text to speech instead, but as you can see I chose the radical solution :-).

The bottom line is that if you work with sound (professionally, as larsH in the thread above), you probably have an additional hi-fi amplifier and ALSA volume problems are non-existent, while sound quality is reportedly higher (compared to PA). On the other hand, for an average day-to-day cheap laptop user like me PA removal makes life a bit worse (see the points above).

Thanks for your attention.

Last edited by Copper36 (2020-10-28 19:14:47)

Offline

#21 2020-11-12 21:57:18

dzhigit
Member
Registered: 2020-11-07
Posts: 14  

Re: High CPU by PulseAudio

Copper36 wrote:

2. A bunch of smaller things, that still might be very important. For example, you one needs PA in order to share sound in ZOOM.

There is a package called apulse which provides a partial implementation of the PulseAudio API for ALSA. The command looks like

apulse zoom

maybe it will fix the issue.

Last edited by dzhigit (2020-11-12 21:57:58)

Offline

Board footer