guitarix
guitarix copied to clipboard
Guitarix at ultra-low latency - CPU affinity
I've been using taskset
to move the guitarix realtime threads to isolated cpus, but since changing presets can spawn new realtime threads, for the convolvers I assume, that are children of the main, non-realtime, thread, It is not a reliable method.
Can you tell me where the primary realtime thread and the convolver realtime threads, are spawned in the code? I will try to use a cpp method to set the affinity and make a new command line option for it.
Hi The primary realtime thread is owned by jackd, not guitarix. The convolver threads been spawned by zita-convolver, /trunk/src/zita-convolver/zita-convolver.cc line 615, called from guitarix in gx_convolver.cpp line 216.
What I observe is that there is one realtime thread owned by Jack, and one (using the -D
CLI switch, two without) owned by guitarix (also more if running any convolvers). Here is a process listing of threads while running guitarix (I moved the non-realtime guitarix parent thread to CPU0 manually with taskset after guitarix started up):
$ ps -eL -o pid,tid,psr,rtprio,pcpu,comm,cmd|egrep "guitar|jackd|%CPU"
PID TID PSR RTPRIO %CPU COMMAND CMD
629 629 0 - 0.0 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
629 632 0 - 0.0 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
629 633 1 - 0.0 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
629 639 0 - 0.0 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
629 640 1 75 11.1 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
629 641 1 - 0.0 jackd jackd --silent -P 75 -d alsa -p 64 -r 96000 -X seq
650 650 0 - 97.4 guitarix guitarix -N -D -C -p 7000
650 652 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 654 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 655 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 656 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 657 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 658 2 - 0.0 guitarix guitarix -N -D -C -p 7000
650 659 2 70 15.3 guitarix guitarix -N -D -C -p 7000
650 660 2 - 0.0 gmain guitarix -N -D -C -p 7000
I can set the affinity of guitarix when it is first called on the commandline, and all other threads will share that affinity, not the affinity of jackd
. I have to manually change the affinity of the realtime thread from the one active non-realtime, parent thread (or vice-versa) after startup to separate them. After that , all convolver threads will share the affinity of the parent thread, and must be moved manually if desired. I'll test setting the affinity of the convolver threads at the point you mention in the code and see if it works.
Anyway, it shouldn't matter who the owner is in terms of cpu affinity. I should just need to use pthread_setaffinity_np
at the point where the thread is created, which should be in your code somewhere. At least that is how I understand it at this point.
650 659 2 70 15.3 guitarix guitarix -N -D -C -p 7000
This should be the convolver thread, it use jack priority - 5. The other one you seen may be the pitch tracker, which use jack priority - 6 so in your setup it should have a priority of 69. (gx_pitch_tracker.cpp line 154) (gx_internal_ui_plugins.cpp line 135 set the priority for the pitch tracker)