On Linux, MPD attempts to configure real-time scheduling for some threads that benefit from it.
This is only possible you allow MPD
to do it. This privilege is controlled by
RLIMIT_RTTIME. You can configure this
privilege with ulimit before launching
ulimit -HS -r 50; mpd
Or you can use the prlimit program from the util-linux package:
prlimit --rtprio=50 --rttime=unlimited mpd
The systemd service file shipped with MPD comes with this setting.
This works only if the Linux kernel was compiled with
CONFIG_RT_GROUP_SCHED disabled. Use the
following command to check this option for your current
zgrep ^CONFIG_RT_GROUP_SCHED /proc/config.gz
You can verify whether the real-time scheduler is active with the ps command:
# ps H -q `pidof -s mpd` -o 'pid,tid,cls,rtprio,comm' PID TID CLS RTPRIO COMMAND 16257 16257 TS - mpd 16257 16258 TS - io 16257 16259 FF 50 rtio 16257 16260 TS - player 16257 16261 TS - decoder 16257 16262 FF 50 output:ALSA 16257 16263 IDL 0 update
CLS column shows the CPU scheduler;
TS is the normal scheduler;
real-time schedulers. In this example, two threads use the
real-time scheduler: the output thread and
the rtio (real-time I/O) thread; these two
are the important ones. The database update thread uses the
idle scheduler ("
ps), which only gets CPU when no other
process needs it.
There is a rumor that real-time scheduling improves audio quality. That is not true. All it does is reduce the probability of skipping (audio buffer xruns) when the computer is under heavy load.