-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixer worker threads do not have rtprio on Linux #5065
Comments
It seems like we have a relevant code in Related: QTBUG-3879 |
The Qt bug says Mac is not affected, but I can't confirm it. Windows have a different scheduling system, but I can't find bugs on Windows. |
MacOS/X mach kernel offers time-constraint scheduling.
However if you use JACK, you should really use the libjack API to create helper threads. |
@x42 Thanks for the information. We may try something similar to what JACK does. |
I strongly think that the fix should be independent of backends. I believe many users are using backends rather than JACK, and we should cover those cases. |
Keep in mind that if you use JACK, your application's internal helper rt-threads should not exceed the priority of jack's main process callback. The straight forward solution is to have each backend provide the appropriate thread-start method. I don't think you can find a common, backend independent cross-platform solution for this. |
Do you have any reasons? No one can know if it's possible before really trying to implement it. |
On 7/28/19 4:07 AM, Hyunjin Song wrote:
Do you have any reasons?
For ALSA your application is responsible for setting up thread priorities.
With JACK your app is at the liberty of how a user configured jackd, on
the upside JACK there's a nice
[API](http://jackaudio.org/api/group__ClientThreads.html)
MacOS mach thread priorities are vastly different. You basically set
time constraints, not priority.
Windows/ASIO is a whole different story as well, depends on what thread
library you use and if the main callback polls and blocks, or runs
directly in the IRQ callback.
No one can know if it's possible before really trying to implement it.
I've tried and succeeded for the most part writing the ALSA and
Coreaudio backends of Ardour and am involved with ASIO/Portaudio backend
and JACK as well
https://github.com/Ardour/ardour/tree/master/libs/backends might come
handy for inspiration. grep for `create_process_thread`.
|
Thank you for the references(https://github.com/Ardour/ardour/blob/master/libs/pbd/pthread_utils.cc as well). LMMS may need slightly different implementations, but that will definitely help. 👍 |
That's also what I would have proposed. E.g. |
Calling
shows that currently only 1 thread (well, 2, for some reasons, but I run this on an >=4 core) has rtprio (realtime priority). Our worker threads do not have rtprio.
The desired behavior is that all worker threads have rtprio. E.g. if you add something like
to the simple client example, you can see two rtprio threads in the
ps
output. Many thanks to @rgareus who found this solution.This should be fixed for jack, and also for ALSA (in the way jack does it when it uses ALSA as backend).
Background:
Realtime priority lets the kernel schedule threads before any non realtime priority threads. If a thread that shall process audio does not have this priority, it may get interrupted ("preemption") by another thread, which can cause lag when you play music while your CPU is busy.
The text was updated successfully, but these errors were encountered: