MinimServer Forum

Full Version: Isolate FFMPEG on a dedicated CPU
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I think the most efficient way to do this is to do a script that launch ffmpeg, then get it PID and make a taskset for the relevant PID
Simon was absolutely right. This script operate as expected :


taskset -c 3 /usr/bin/ffmpeg "$@"

Now it's time to check the minimserver.service file. Simon, do you have any advice where to find it on debian 10 ?

Or how to set CPUaffinity for Minimser at boot ?

I installed Debian 10 to check this. It has support for SysVinit as well as systemd. In this situation, MinimServer chooses to use SysVinit and creates a minimserver file in the /etc/init.d directory. It is not advisable to try to modify the /etc/init.d/minimserver file to set processor affinity for the MinimServer process because the minimserver/bin/setup script reads and parses this file in some situations.

The best way to do what you want is to create a file in the minimserver/etc directory named minimstart.conf and containing just the following line:

JAVA=taskset -c 3 java
Hello Simon,

Thank. Unfortunately this don't operate as expected. I've done a chmod 755 on the file 'minimstart.conf' to see what happen and it doesn't change anything.

Is this trick operate with your test system ?

you can check which process runs on CPU 2 and 3 with this command line :

ps -eo psr,command | tr -s " " | grep "^ [2|3]"

I checked this and found why it isn't working.

1) The line should start java= and not JAVA=

2) You need to do the same as you did for ffmpeg: create a script that invokes java via taskset and put the path to this script in the java= line in minimstart.conf. Unlike the ffmpeg script, this script can have any name (I used The script needs chmod 755 but you don't need this for the minimstart.conf file because this file is being read by the startd script, not executed.

3) For this use of taskset to launch java, it is important that the java process is run as a direct child of the startd process. To make this happen, you need to put exec before taskset, like this:

exec taskset -c 3 java "$@"

It would be a good idea to add the exec for ffmpeg as well.
Thank Simon.

I confirm that this method is OK.
Did you try this trick and found any improvement ?

First thing to do is to use "isolcpus" in grub.conf to exclude 2 cores from the linux scheduler, than to put scripts like we discuss to have minim running on one excluded cpu and ffmpeg on the other.
I don't have a 4-core processor to try this on. Also, I run MinimServer on a Melco which has only a single core and the sound quality is excellent. Smile

Did you compare having MinimServer and FFmpeg on the same isolated CPU with having them on different isolated CPUs? Which of these do you think sounds better?
(15-01-2020 09:25)simoncn Wrote: [ -> ]Did you compare having MinimServer and FFmpeg on the same isolated CPU with having them on different isolated CPUs? Which of these do you think sounds better?

I didn't tried yet. Will do and report.
I finally give a try to use the same core for ffmpeg+minim vs one core for each. There is no sensible difference.
In fact, when using ffmpeg for transcode, the transcode is done at the very beginning of the reading process, and only last a few time. I don't know if the transcode file is really a temp file or in ram.
Thanks for this information.

Transcoding is done to RAM. If it only happens for a short time, it must be a small file.
Pages: 1 2 3
Reference URL's