PulseAudio CPU Hogging
If your laptop’s fan has been doing the back‑and‑forth dance or the CPU clock keeps climbing while you’re just listening to a playlist or watching a video, you’ve probably run into PulseAudio’s infamous CPU bloat. The daemon is built for flexibility, not for squeezing every watt out of a laptop, and its out‑of‑the‑box settings can turn a modest machine into a little CPU hamster.
Why PulseAudio Can Be a CPU Hamster
The resampling engine runs in user space and gets hit for every stream that needs a sample‑rate or format change. By default it uses soxr, a high‑quality but heavy algorithm. Combine that with the default 48 kHz sample rate and 32‑bit float format, and you’re looking at a few percent of a core even when the system is otherwise idle. On older hardware or when the battery is low, that overhead shows up as a fan spin or a temperature spike.
The Simple Config Tweak
The quickest way to shave CPU usage is to tell PulseAudio to use a lighter resampler and a less demanding sample format. Edit (or create) ~/.config/pulse/daemon.conf and drop in:
# Use a lightweight resampler
resample-method = speex-float-10
# Prefer 16‑bit signed samples – less work for the CPU
default-sample-format = s16le
# Optional: lower the default sample rate
default-sample-rate = 44100
speex-float-10 is a 10‑band Speex resampler that keeps quality high enough for most music and voice while cutting CPU load. s16le is the classic 16‑bit little‑endian format that almost all hardware can handle natively. Dropping the sample rate to 44.1 kHz removes the extra 48 kHz overhead without a noticeable drop in audio quality for most media.
Link: PulseAudio documentation on freedesktop.org.
Applying the Change
PulseAudio runs per‑user, so you can just restart it:
pactl quit
pulseaudio --start
On most modern distros that use systemd user units, the restart will be handled automatically. Verify that the new settings are in effect:
pactl info | grep -E 'Resample|Sample format|Sample rate'
You should see speex-float-10, s16le, and 44100.
Verifying the Impact
Open a terminal and run htop. Look for the pulseaudio process. On a typical laptop, you’ll see its CPU usage drop from 5–10 % to under 2 %. If you’re still seeing high usage, try disabling the module-udev-detect module (which handles hot‑plugging) by adding load-module module-udev-detect to your default.pa with the disable flag, or simply comment it out if you don’t need hot‑plug support.
Trade‑offs and Caveats
- Audio Quality: The Speex resampler is fine for most music and voice. If you’re a professional audio editor, you might notice a slight degradation. In that case, keep
soxrand accept the CPU cost. - Legacy Hardware: Some older sound cards only support 16‑bit samples. Switching to
s16leis safe, but if you have a device that requires 32‑bit float, you’ll need to revert. - Multiple Streams: If you run many applications that produce audio simultaneously (e.g., a music player, a video call, and a game), the CPU savings compound. On a single‑stream workload, the benefit is smaller.
When to Consider PipeWire
Many distros now ship PipeWire as a drop‑in replacement for PulseAudio. PipeWire is designed to be lightweight and integrates better with Wayland. If you’re on a recent distro and your workload is audio‑heavy, switching to PipeWire can yield further CPU savings without manual tweaking. The transition is usually as simple as:
sudo apt remove pulseaudio
sudo apt install pipewire pipewire-pulse
(Replace apt with your distro’s package manager.)
Link: Arch Linux wiki on PulseAudio.
Security Note
PulseAudio runs as a per‑user daemon, so it doesn’t elevate privileges. The configuration changes above do not introduce new security risks. However, if you ever run PulseAudio as a system service (rare), make sure the systemd unit is confined with systemd‑scope or systemd‑cgroup to prevent audio data from leaking between users.
See also
- Pulling the top 10 HTTP status codes from an Nginx access log with awk
- Restoring a Half‑Completed Borg Backup That Stopped at 50%
- I kept my home server from going down during Let’s Encrypt renewal – here’s the one‑liner timer I added.
- The Quick Fix to Stop a Flatpak App From Updating on My Wayland Desktop
- Stopping the Journal from Flooding me with Repeated Wi‑Fi Disconnection Notices