MinimServer Forum
Isolate FFMPEG on a dedicated CPU - Printable Version

+- MinimServer Forum (https://forum.minimserver.com)
+-- Forum: MinimServer (/forumdisplay.php?fid=1)
+--- Forum: MinimStreamer (/forumdisplay.php?fid=11)
+--- Thread: Isolate FFMPEG on a dedicated CPU (/showthread.php?tid=5500)

Pages: 1 2 3


Isolate FFMPEG on a dedicated CPU - lafuente - 12-01-2020 17:13

Hi Simon,

I'm still working on tests with Minimserver and Linux, with the main purpose to test anything I'm think about.

Recently, after having installed a RT kernel, fix CPU freq and latency using frequtils, I got a real improvement on the sound.

Today I tried to use taskset to assign specific CPUs to minimserver and ffmpg.

So I had "isolcpus=2,3" to grub conf reserve the 2 last cores of my CPU to this purpose.
Then it was easy to set minimserver to use cpu 3 using "taskset -cp 3 MinimServer_ID"

Problems comes when I wanted to dedicate cpu 2 to ffmpeg. Because ffmpeg is launched at each song, with a different ID each time.

so I'd like to know if there is way to force ffmpeg to always use CPU2, whatever happen ?

Also, I didn't look at the way to get minim running on CPU 3 at each boot. Is this possible ?

Last thing : do you think that this is the right thing to do ?

Thank,
Manu


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 12-01-2020 17:33

Per default, when minimserver run on an "affected" CPU, FFMPEG sometime use the same core due to it PPID. If I assign 2 CPUs to minim, FFMPEG still use the same CPU than Minim, or not...

Maybe can I "pass" an option from minim when it launch FFMPEG ?


RE: Isolate FFMPEG on a dedicated CPU - simoncn - 12-01-2020 17:42

From a quick look at the taskset commend, you can use it to change the affinity of a running process, so you could try changing the affinity of the ffmpeg process while it is transcoding a song to see if you can hear any difference between running FFmpeg on the same CPU as MinimServer and running FFmpeg on a different CPU. If the song is quite long, you can switch back and forth to confirm your impressions. I think this should be the first step before trying anything else.

I think it is possible that processor affinity might make a difference to sound quality and I think it is useful for you to try these experiments.


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 12-01-2020 18:45

Thank Simon,

I must admit that there is no gap here. I will test at a colleague home because he have a better audio system than mine. Mine is correct, but not high-end.

The fixed processor speed is more noticeable with his system than with mine. So maybe the CPUs affectation is the same...

I'll update the post when I'll fixed about this.

Last : to allow the CPU choice to be fixed at startup without typing any command line, I have to add

Code:
[Service]
CPUAffinity=3

to the miniserver service script. Where do I need to add this please ?

Regards,
Manu


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 12-01-2020 19:25

Correction : I didn't apply the correct CPU isolation at begining of the tests.

Using it in the correct way improve sound (not many, but anything is good to grab).

Difficult to me to explain the impress in English, but the flow is more soft...


RE: Isolate FFMPEG on a dedicated CPU - simoncn - 12-01-2020 22:45

The service file is located at /usr/lib/systemd/system/minimserver.service


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 13-01-2020 13:31

(12-01-2020 22:45)simoncn Wrote:  The service file is located at /usr/lib/systemd/system/minimserver.service

In my debian 10, there is not such a file at this location. If I use "find" I have files here :

Code:
root@audio:/usr/lib/systemd/system# find / -name minimserver.service

/sys/fs/cgroup/memory/system.slice/minimserver.service
/sys/fs/cgroup/devices/system.slice/minimserver.service
/sys/fs/cgroup/systemd/system.slice/minimserver.service
/sys/fs/cgroup/unified/system.slice/minimserver.service
/run/systemd/generator.late/minimserver.service
/run/systemd/generator.late/graphical.target.wants/minimserver.service
/run/systemd/generator.late/multi-user.target.wants/minimserver.service



RE: Isolate FFMPEG on a dedicated CPU - simoncn - 13-01-2020 13:52

How did you enable automatic startup for MinimServer? If you do this using the minimserver/bin/setup command on a system that supports systemd, it should put a minimserver.service file at the location I described.


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 13-01-2020 14:10

I think I used "startc" script rather than "setup". Unsure...


RE: Isolate FFMPEG on a dedicated CPU - lafuente - 13-01-2020 14:13

(13-01-2020 14:10)lafuente Wrote:  I think I used "startc" script rather than "setup". Unsure...

I redo my setup and confirm that I used ./setup