Volumio Process Priority and CPU Set

A DIY digital music streamer with exceptional performance

Moderator: Staff

Post Reply
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Volumio Process Priority and CPU Set

Post by springwood64 »

I have applied process priority and CPU Set allocation for Volumio and to my ears it brings a similar improvement that it did to SnakeOil.

I created a 'music' CPU Set and allocate MPD and vollibrespot to it.

Here's the script to create the 'music' CPU Set, install 'cset' and allocate CPU 0 to 'music', which just needs to be run once after installing Volumio:

Code: Select all

mkdir /sys/fs/cgroup/cpuset/music
apt-get update
apt-get install cpuset
cset set -c 0-0 music
cset set -m 0-0 music
I created a script to be run after reboot that sets mpd and vollibrespot to RT priority and assigns them to the 'music' CPU Set. This means they will only execute on CPU 0, and will never be switched to another CPU:

Code: Select all

pids=$(pgrep -x mpd)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move  --threads --toset=music --force --pid=$pid
done
pids=$(pgrep -x vollibrespot)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move  --threads --toset=music --force --pid=$pid
done
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

If you want to experiment with changing the CPU allocation, then just use the 'cset set -c <cpu spec> music' command.

Eg to switch to CPU 1:

Code: Select all

cset set -c 1-1 music 
Or to switch to CPU 2 & 3:

Code: Select all

cset set -c 2-3 music 
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

It turns out that the CPU Set has to be recreated after every reboot.

I have also found a more elegant mechanism provided by 'cset' called 'shield'.

This better separates the CPUs into two sets: 'user' and 'system'. The shield command creates a 'user' set and moves most processes into 'system'.

Allocating 1 CPU to 'user' via the shield command means that the processes running 'user' have fewer competing processes for that CPU.

This is the script that needs to be run once to install cset, once Volumio is installed:

Code: Select all

apt-get update
apt-get install cpuset
This is the script that needs to be run a few minutes after reboot, to create the shield and move mpd and vollibrespot into the 'user' set (allocating CPU 0 to the 'user' set):

Code: Select all

cset shield -c 0-0
pids=$(pgrep -x mpd)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move  --threads --toset=user --force --pid=$pid
done
pids=$(pgrep -x vollibrespot)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move  --threads --toset=user --force --pid=$pid
done
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
Lego
Very active member
Very active member
Posts: 1147
Joined: 2007-04-18 11:42
Location: glasgow

Re: Volumio Process Priority and CPU Set

Post by Lego »

So what improvements are you getting exactly ?
I know that tune
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

When I posted clips recorded of Snakeoil comparing CPU allocation vs no CPU allocation, Beck described the CPU allocation as adding 'umami', which I like as a description: an improvement in the flavour of the sound :)

I've created a Volumio plugin (Music Services Shield) and submitted it for approval to Volumio. I'll post on this thread when it's been published. That will make it easy for anyone using Volumio to try this optimisation.
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
Lego
Very active member
Very active member
Posts: 1147
Joined: 2007-04-18 11:42
Location: glasgow

Re: Volumio Process Priority and CPU Set

Post by Lego »

springwood64 wrote: 2021-06-28 07:16 When I posted clips recorded of Snakeoil comparing CPU allocation vs no CPU allocation, Beck described the CPU allocation as adding 'umami', which I like as a description: an improvement in the flavour of the sound :)

I've created a Volumio plugin (Music Services Shield) and submitted it for approval to Volumio. I'll post on this thread when it's been published. That will make it easy for anyone using Volumio to try this optimisation.
Great Springwood ,look forward to trying it ,but I'm guessing it's for pcs rather than Tinkerboards.
I know that tune
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

Lego wrote: 2021-06-28 23:04 Great Springwood ,look forward to trying it ,but I'm guessing it's for pcs rather than Tinkerboards.
It'll work for tinkerboard and RPi.

The cset mechanism works for Debian and Ubuntu, so can apply to any compatible platform with 2 or more logical CPUs
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
Lego
Very active member
Very active member
Posts: 1147
Joined: 2007-04-18 11:42
Location: glasgow

Re: Volumio Process Priority and CPU Set

Post by Lego »

springwood64 wrote: 2021-06-29 06:40
Lego wrote: 2021-06-28 23:04 Great Springwood ,look forward to trying it ,but I'm guessing it's for pcs rather than Tinkerboards.
It'll work for tinkerboard and RPi.

The cset mechanism works for Debian and Ubuntu, so can apply to any compatible platform with 2 or more logical CPUs
Thanks Springwood,what improvements can I expect?
I know that tune
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

I am running in a new Tinker Board S + ESI Gigaport Ex, so I don't yet know what the impact of shielding the processes will sound like.

However you can now try yourself. The plugin 'Music Services Shield' is now available for Arm (Raspberry Pi and Tinker Board) (under Miscellanea plugins).

Install it and enable it. You will need to turn it off/on after each reboot because I haven't figured out how to invoke it on volumio restart.
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
matthias
Very active member
Very active member
Posts: 2092
Joined: 2007-12-25 16:47
Location: Germany

Re: Volumio Process Priority and CPU Set

Post by matthias »

springwood64 wrote: 2021-07-01 07:52 I am running in a new Tinker Board S + ESI Gigaport Ex.......
Pete,

any comment on the performance of the Gigaport eX?

Matt
Matt

MBP / Exposure pre + power (both modified) / JBL3677
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

matthias wrote: 2021-07-01 11:01 Pete,

any comment on the performance of the Gigaport eX?

Matt
It's too soon really - I'm still running it in. I haven't tune dem'd it.

However, first impressions are that it compares very closely to the HD+.

I'll burn it in for a week or so and then compare it to the HD+ as well as comparing the Hakai to the Tinker Board S.
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
matthias
Very active member
Very active member
Posts: 2092
Joined: 2007-12-25 16:47
Location: Germany

Re: Volumio Process Priority and CPU Set

Post by matthias »

springwood64 wrote: 2021-07-01 11:06 It's too soon really - I'm still running it in. I haven't tune dem'd it.
However, first impressions are that it compares very closely to the HD+.
I'll burn it in for a week or so and then compare it to the HD+ as well as comparing the Hakai to the Tinker Board S.
Thanks,
looking forward to both comparisons :-)

Matt
Matt

MBP / Exposure pre + power (both modified) / JBL3677
Lego
Very active member
Very active member
Posts: 1147
Joined: 2007-04-18 11:42
Location: glasgow

Re: Volumio Process Priority and CPU Set

Post by Lego »

springwood64 wrote: 2021-07-01 07:52 I am running in a new Tinker Board S + ESI Gigaport Ex, so I don't yet know what the impact of shielding the processes will sound like.

However you can now try yourself. The plugin 'Music Services Shield' is now available for Arm (Raspberry Pi and Tinker Board) (under Miscellanea plugins).

Install it and enable it. You will need to turn it off/on after each reboot because I haven't figured out how to invoke it on volumio restart.
Thanks !
I know that tune
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

I have released v1.2.0 of the Volumio plugin: https://community.volumio.org/t/volumio ... n/38741/84

If you try it out, let me know what you think.

The Volumio team have not published the plugin for x86, but I'm running it on my Hakai as well as my Tinker Board and another x86 and it works fine.
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

Volumio have published the plugin for x86 too, so it is available for standard Hakai builds.
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
fatjulio
Active member
Active member
Posts: 159
Joined: 2012-01-13 23:22

Re: Volumio Process Priority and CPU Set

Post by fatjulio »

I tried the script and the plug-in, and prefer not having it. Assigning the priorities makes it less musical and rich.
User avatar
springwood64
Very active member
Very active member
Posts: 789
Joined: 2008-10-13 18:19
Location: UK

Re: Volumio Process Priority and CPU Set

Post by springwood64 »

fatjulio wrote: 2021-07-24 01:34 I tried the script and the plug-in, and prefer not having it. Assigning the priorities makes it less musical and rich.
On my Tinkerboard S I prefer running with the following options :
  • MPD and Spotify shielded in CPU 1-3
  • MPD priority set to 40 - this is lower than the realtime IO task for MPD which is set to 50 and unaltered by the plugin
  • No priority for Spotify
Pete

Linn Axis, Kinki, Källa (GS308T+Amplifi HD x 2 + BJC), Boazu, Espeks
Post Reply