CpuSet Feature While Using Upmpdcli
|
Posts: 6
Threads: 2
Joined: May 2020
Reputation:
0
Hi,
I enabled cpuset package and 'm pusing mconnect app with upmpdcli, everything is perfect.
Yesterday, I controlled CPU usage and allocations, and I saw that Upmpdcli was working on CPU1 (user), but MPD was working on CPU0 (system).
As far as I know, music player(mpd) should play on CPU1 for best sound. I want to isolate upmpd and mpd on CPU1 from every other thing that is working on CPU 0.
As you can see, PID numbers:
MPD: 1197,
Upmpdcli: 1181
You can see that Upmpdcli is working on CPU1, while MPD is working on CPU0.
So, What can I do for isolating MPD on CPU1 with Upmpdcli on startup? I have some Linux skills then I'm open for all suggestions
Thank you,
Posts: 2,783
Threads: 178
Joined: Feb 2016
Reputation:
482
Location: Perth, WA
06-Oct-2020, 01:36 PM
(This post was last modified: 06-Oct-2020, 01:38 PM by agent_kith.)
Hmm.. Can you try and run:
Code: sudo cset proc --move --pid=PID --threads --toset=user --force
Replace PID (e.g. 1197) with the current PID, and let me know how it goes.
That's the current workaround for now while I work on why it didn't move it before. I suspect this is a race condition (MPD didn't start quick enough), or I only moved the server app, but not the client app!
Have created a ticket, and I'll sort it out in the next release.
Snakeoil Operating System - Music, your way!
Posts: 642
Threads: 37
Joined: Mar 2019
Reputation:
150
Location: Melbourne, Australia
06-Oct-2020, 07:57 PM
(This post was last modified: 07-Oct-2020, 07:05 PM by Snoopy8.)
(06-Oct-2020, 01:36 PM)agent_kith Wrote: Hmm.. Can you try and run:
Code: sudo cset proc --move --pid=PID --threads --toset=user --force
Replace PID (e.g. 1197) with the current PID, and let me know how it goes.
That's the current workaround for now while I work on why it didn't move it before. I suspect this is a race condition (MPD didn't start quick enough), or I only moved the server app, but not the client app!
Have created a ticket, and I'll sort it out in the next release. Adding my scenario of using MinimServer with upmpdcli.
I have 4 cores, cores 0 & 1 allocated for system, cores 2 & 3 for music player. Mpd is using Core 1. Upmpdcli is using Core 2. Minimserver (running Java) is using Core 0. Is MinimServer considered part of system or player?
Posts: 6
Threads: 2
Joined: May 2020
Reputation:
0
(06-Oct-2020, 01:36 PM)agent_kith Wrote: Hmm.. Can you try and run:
Code: sudo cset proc --move --pid=PID --threads --toset=user --force
Replace PID (e.g. 1197) with the current PID, and let me know how it goes.
That's the current workaround for now while I work on why it didn't move it before. I suspect this is a race condition (MPD didn't start quick enough), or I only moved the server app, but not the client app!
Have created a ticket, and I'll sort it out in the next release.
Yes, it worked! But with each startup, PID of Mpd changes. So I need to otomate the command with updated PID number at startup.
Posts: 2,783
Threads: 178
Joined: Feb 2016
Reputation:
482
Location: Perth, WA
This will be fixed in the next update so you don't have to do this manually.
But until then, for a workaroud, you can run something like pgrep to find the PID of MPD.
Snakeoil Operating System - Music, your way!
Posts: 642
Threads: 37
Joined: Mar 2019
Reputation:
150
Location: Melbourne, Australia
08-Oct-2020, 09:41 AM
(This post was last modified: 08-Oct-2020, 09:43 AM by Snoopy8.)
Also, when running Mpd by itself, on CPU 3 (2 & 3 allocated to player), Mympd is running in the background using CPU 1 (0 & 1 allocated to system). Should Mympd be running in the background? If so, then should it not be running on a CPU allocated to player?
Posts: 18
Threads: 2
Joined: Jun 2020
Reputation:
4
Location: UK
(07-Oct-2020, 02:08 PM)agent_kith Wrote: This will be fixed in the next update so you don't have to do this manually.
But until then, for a workaroud, you can run something like pgrep to find the PID of MPD.
I've created a script to set the mpd priority to real time and to move mpd to user:
Create new file mpdpriority.sh with the following lines:
sudo chrt -r -p 99 $(pgrep mpd)
sudo cset proc --move --threads --toset=user --force --pid=$(pgrep mpd)
You can then run this manually as sudo sh [path to script file]/mpdpriority.sh
Or set it to run after boot:
#crontab-e
@reboot root sh [path to script file]/mpdpriority.sh
Posts: 2,783
Threads: 178
Joined: Feb 2016
Reputation:
482
Location: Perth, WA
(08-Oct-2020, 10:32 PM)PeteCallaghan Wrote: Or set it to run after boot:
#crontab-e
@reboot root sh [path to script file]/mpdpriority.sh This will have the same problem with the current setup, as the script could be run before MPD has finished starting up... A workaround is to create a for loop (with sleep to throttle it down), and loop until pgrep returns a PID.
Snakeoil Operating System - Music, your way!
Posts: 18
Threads: 2
Joined: Jun 2020
Reputation:
4
Location: UK
09-Oct-2020, 06:22 PM
(This post was last modified: 09-Oct-2020, 06:34 PM by PeteCallaghan.)
(09-Oct-2020, 09:21 AM)agent_kith Wrote: (08-Oct-2020, 10:32 PM)PeteCallaghan Wrote: Or set it to run after boot:
#crontab-e
@reboot root sh [path to script file]/mpdpriority.sh This will have the same problem with the current setup, as the script could be run before MPD has finished starting up... A workaround is to create a for loop (with sleep to throttle it down), and loop until pgrep returns a PID.
You are right - I can't get this to work after reboot, even with this:
Code:
while ! pgrep mpd >> /dev/null ;
do
sleep 5
done
(09-Oct-2020, 06:22 PM)PeteCallaghan Wrote: (09-Oct-2020, 09:21 AM)agent_kith Wrote: (08-Oct-2020, 10:32 PM)PeteCallaghan Wrote: Or set it to run after boot:
#crontab-e
@reboot root sh [path to script file]/mpdpriority.sh This will have the same problem with the current setup, as the script could be run before MPD has finished starting up... A workaround is to create a for loop (with sleep to throttle it down), and loop until pgrep returns a PID.
You are right - I can't get this to work after reboot, even with this:
Code:
while ! pgrep mpd >> /dev/null ;
do
sleep 5
done
There seemed to be multiple mpd processes, so a loop was needed to catch them all:
Code:
pids=$(pgrep mpd)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move --threads --toset=user --force --pid=$pid
done
Posts: 2,783
Threads: 178
Joined: Feb 2016
Reputation:
482
Location: Perth, WA
(09-Oct-2020, 06:22 PM)PeteCallaghan Wrote: There seemed to be multiple mpd processes, so a loop was needed to catch them all:
Code:
pids=$(pgrep mpd)
for pid in $pids
do
chrt -r -p 99 $pid
cset proc --move --threads --toset=user --force --pid=$pid
done
In theory you don't have to do this, just find the main PID, and the --threads option will move all threads to the CPUSet.
But, that's really dependent on how MPD works.. e.g. if MPD fork a thread on playback, there is always a chance this script will not work.. i.e. MPD starts, and the script moves the threads to the CPU Set, and when you play, MPD fork another thread, this is not trapped by the script as it happens after the fact..
There's prob a way to fix this, but I havn't investigate deeply enough yet... The current script, while brutally simple, actually yield quite a good audio improvement.. But I've mostly tested this in LMS and Squeezelite..
Please continue to explore this and let me know your progress, I'll incorporate your work into the next release too.
Snakeoil Operating System - Music, your way!
|
Users browsing this thread: |
1 Guest(s)
|
|
Welcome
|
You have to register before you can post on our site.
|
SnakeoilOS Mission Statement
|
Our mission is to create a free to use computer OS that is easy to install, intuitive to operate and play music that will connect and engage with you emotionally.
SnakeoilOS gives you the freedom to spend more time on listening, enjoying and exploring music. Wasting time on computers is now a thing of the past! Everything is constantly evolving/improving. Please check back often for updates.
If you like this project, do show your support with a small token donation. All donations collected will be used to run this website, and for purchasing new equipment for the project.
|
|
|