[PLUGIN] Music Services Shield

Music Services Shield is a plugin that allows you to separate the resources used by Volumio music processes from other processes, to improve audio quality.

3 Likes

See this thread for discussion of the thinking behind this plugin: CPU Set and process priority

Version 1.0.x

On installation, the plug-in installs the ‘cset’ package. It uses this to create a ‘user’ and ‘system’ group of CPUs.

CPU 0 is allocated to ‘user’ and the remaining CPUs to ‘system’.

The processes for ‘mpd’ and ‘vollibrespot’ (Spotify Connect) are allocated to ‘user’ and assigned real time priority. All other processes are assigned to ‘system’.

This should reduce the number of processes sharing CPU with the music processes.

The plug-in applies the allocations when it is enabled or when Volumio starts. It relies upon the music processes starting beforehand.

If these processes are restarted, then the plug-in will need to be stopped and started again to allocate the new processes to ‘user’.

1 Like

Version 1.0.2

This version allows the display of the processes allocated to ‘user’, from the plug-in settings.

1 Like

Version 1.1.0
It is now possible to configure the shield.

User Group CPUs
Use this to allocate selected CPUs to the ‘user’ group. Music services will be assigned to the ‘user’ group. The remaining CPUs will be allocated to the ‘system’ group. All other processes will run on the ‘system’ group of CPUs.

Shield MPD
If set to ‘On’, MPD will be shielded in the ‘user’ group.

Shield Spotify Connect
If set to ‘On’, Spotify Connect will be shielded in the ‘user’ group.

Set MPD Priority
If set to ‘On’ the priority of MPD will be changed.

Set Spotify Priority
If set to ‘On’ the priority of Spotify will be changed

Process Priority
The priority value to apply to music processes.

These changes are all applied on ‘Save’ or when Volumio restarts.

If you restart the music processes (for example after changing their settings) you will need to save the Music Services Shield settings again to re-apply the shield.

1 Like

Awesome work. I will try and update to your new version when possible (plug in section mentions only 1.01 for now)

thanks for the plugin i tried also the first version and works fine. how you can update it to the latest version?

The new version has not been merged and released yet. I’ll post here when it’s available.

3 Likes

Version 1.2.0

Installs music services shield as as systemd service so that it automatically recreates the shield when MPD or Spotify Connect restart.

Available as a pre-release here: Release v1.2.0 · petecallaghan/volumio-plugins · GitHub

3 Likes

Nice work :slight_smile: Was it sufficient to just add the PartOf?

1 Like

After some research, I went for this:

[Unit]
Description=Shield Volumio Music Services in the User CPU Set
Documentation=https://community.volumio.com/t/plugin-music-services-shield/48519
Requires=mpd.service
After=mpd.service
PartOf=mpd.service
Requires=volspotconnect2.service
After=volspotconnect2.service
PartOf=volspotconnect2.service

[Service]
Type=oneshot
User=root
Group=root
ExecStart=/bin/bash /data/plugins/miscellanea/music_services_shield/moveallprocesses.sh
RemainAfterExit=true
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=volumio

[Install]
WantedBy=multi-user.target

It’s a ‘oneshot’ because it’s a short lived bash script

1 Like

On further reading, I have removed ‘Requires’. This will be included in the next release. It is not needed and would prevent the service from working if either MPD or volspotconnect2 are not enabled.

1 Like

Please post here with your feedback on this plugin, and share your results of experimenting with different settings.

I am currently using CPUs 0-2 for user (3 for system), with MPD and Spotify Connect included in the shield but no change to process priority. To my ears this sounds significantly more enjoyable than no shield active on my Gigabyte 3150 (x86).

2 Likes

If you’re interested in the progress of adding support for cgroup slices, check this issue: Add option to apply a systemd cgroup/slice · Issue #15 · petecallaghan/volumio-plugins · GitHub

1 Like

Hi, I just installed this plug in. So far all seems to be just fine. Perhaps a stupid question, when setting priority, what is a higher priority…10 or 90?

I have the application running on a Rpi-4 using USB out to a DAC, use mostly for Spotify.
Thanks for the support,
Mitch

1 Like

90 is high 10 is low.

Hi Pete, as you already know I love this plugin. With my settings (CPU 0-2 and priority at 60,70,80 or 99) my raspberry pi 3b based streamer becomes unresponsive sometimes (only reboot from SSH was possible). I use only the mpd shield. Any advice on stable + best sounding settings?

Hi Vennesch. I am still experimenting. I have a Tinkerboard S and a couple of x86 systems and each seems to be different. Have you tried disabling the priority?

1 Like

If it is still prone to becoming unresponsive, try selecting CPU 0-1 to free up more processing to other services.

1 Like

I will try to set less priority until it’s stable. If that doesn’t work I will disable priority. Will report what works best on my setup. And will try your other suggestion if it doesn’t work al together.

With my former processor isolation trick 2 and 3 worked like a charm will try that as well

Edit: priority at 80. No problems. System is fast.

1 Like