-
-
Notifications
You must be signed in to change notification settings - Fork 67
Fix Android thread priority #1280
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
base: develop
Are you sure you want to change the base?
Fix Android thread priority #1280
Conversation
Android threads are Linux threads which differ from the POSIX standard. Calling pthread_setschedparam does not produce the intended effect on Android.
@atsushieno you have more Android experience than I do, if you find some time to have a look I will defer to your judgment :) Thanks! |
@paulfd okay, but I was not aware of this platform-specific difference either, so I'm reviewing from that stand point. @chucknology Reviewing without actually running code so far - I agree to the change in general, but it seems that the intent of setting priority there is so that it gives "moderately higher" priority than normal thread, not "highest" (-20). The default value for
|
@atsushieno @paulfd thanks for your consideration. My understanding is that Android's priority values map to Linux priorities (i.e.
The comments in that class suggest that the "top app" has its main(UI) and render threads priorities "boosted" to -10, so I surmise that a lower value(higher priority) than that might be appropriate to be impactful in most cases. In our application we uncovered and addressed significant performance bottlenecks elsewhere (unrelated to sfizz) so it was difficult to evaluate the actual benefit of this change in isolation. I can say that there have been no apparent adverse effects. I did confirm that the implementation I've offered appears to work, remaining set to the desired priority - and the system complains appropriately when trying to set invalid values. I'd propose setting the priority to |
Ahh, thanks for the clarification for each value. That helps me understand the appropriate usages for each value. I don't think -19 or even -16 should be given to this "background loader" thread. Recently I have investigated the Android audio framework internals (namely audioserver) and figured that It should be noted that audio applications like YouTube Music still does NOT use AAudio, and still its background audio playback takes most priority e.g. it keeps playing music while the UI is not responsive. It applies to any media application that depends on Jetpack Media3 (ExoPlayer). -19 and -16 are SUCH high priority values, and definitely not for background threads. Have you verified your app behavior with any priority like |
I'm OK to merge if you're good with it! |
Android threads are Linux threads which differ from the POSIX standard.
Calling pthread_setschedparam does not produce the intended effect on Android.