-
Notifications
You must be signed in to change notification settings - Fork 762
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
Disable AppNap in QtCollider, sclang, and scsynth #1011
Conversation
|
Supernova is a replacement for scsynth, that supports parallel processing of DSP on multi-core processors. If app nap is bad for scsynth, it's bad for supernova too. |
// On Mac, we may need to disable "App Nap", so we aren't put to sleep unexpectedly | ||
SC::Apple::disableAppNap(); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict, there is no need for this: QtCollider is part of sclang, so it does not need to disable app nap by itself.
@snickell regarding your questions:
also a more general question: does appnap take process priorities into account? didn't look into it, but sclang threads run at a higher priority than normal processes ... |
Unfortunately, AppNap's behavior is relatively undefined (the same way as the OS scheduler's behavior is relativey undefined) and subject to change behind the scenes on future OS updates. Its all hinting, no promises. The more accurately/profusely we hint, the less likely we are to get the rug pulled in the future. As apple releases future updates I suspect they will get more aggressive about power saving, and throttle things back more and more, so my philosophy here is "when in doubt, hint we are doing something that needs quality timers and scheduling". Obviously the higher priority of sclang threads alone wasn't enough to disable appnap, since we were observing negative napping behavior there. In any case, the calls we are making aren't strictly speaking "disabling AppNap", they are informing OS/X that "this process is performing a user-observable activity that should be kept responsive". Additionally, we are telling OS/X that we want the best timer-resolution it can provide (most relevant to scsynth). scsynth /probably/ wont' get appnapped already, because OS/X is /likely/ to notice that its using CoreAudio, and guess that nappiong something actively using CoreAudio is a BadIdea(TM). While it may not get appnapped even without hinting, its possible scsynth will get higher precision timers if it asks for them though, and I think that's a positive thing. If we wanted to get fancier, we could probably turn the activity on/off depending on whether any synths were running or not, so if you are just working on the IDE without any synths you get a longer battery life, but I think that's much more bug prone and not worth blocking on. |
Mac folks: any reason not to merge this? Tim pointed out one bit of unneeded code https://github.com/supercollider/supercollider/pull/1011/files#r8541216 but that aside? |
two points:
|
aja, it checks the obj-c runtime ... so disregard my first point |
I am quite surprised we don't have more complaints about this issue... I usually integrate this pullrequest in my build. Today I made a build from clean master without this PR and immediately had serious trouble whith the server taking a looong time to boot (10 s) and sometimes not booting at all... This should not get lost, most people who run into this will not be able to find out the reason and loose a lot of time trying to find out what is going on. |
Well, I think it'd be good to add the feature to supernova, and remove the unneeded one in qtcollider. It'd be lovely if @snickell could update the patch, but if not then I don't see any harm in merging-and-tweaking it. |
I'd love to update, but not really having the time right now, so probably On Mon, Oct 6, 2014 at 12:23 AM, danstowell notifications@github.com
|
Disable AppNap in QtCollider, sclang, and scsynth - thanks @snickell
Just as for the record and to think about when 3.6.7-osx comes out. This patch doesn't compile in an old build environment (required for OSX-10.6/universal-build compatibility). I get:
|
@bagong thanks. It would be handy to avoid breakage if it's easy, so perhaps you could see if there's an appropriate #if we can add to SC_Apple.mm? I think 10.6 is not used by the mac devs now...? |
Well, the easiest would be not to apply the patch to 3.6, or to split into two branches, one that still works for old systems and 32-bit macs, and one that could be built in a newer environment and work well in 10.9 upwards. But if 3.7 finally hits the world, that might not be necessary? :) |
i'd recommend not to support more than 3 osx versions in one codebase: apple continuously changes its APIs and keeping compatibility with older osx versions is a great way to waste time. |
Hm, something fishy here.... The code in SC_Apple.mm "should" compile against 10.0 (!) let alone 10.6. This is a linker issue. Its not finding the NSProcessInfo class itself, On Tue, Oct 7, 2014 at 9:16 AM, Rainer Schütz notifications@github.com
|
Yeah, but this code SHOULD be 10.0 compatible, let alone 10.6. There's On Tue, Oct 7, 2014 at 10:10 AM, Tim Blechmann notifications@github.com
|
@bagong: are you compiling from within xcode? On Tue, Oct 7, 2014 at 10:13 AM, Seth Nickell snickell@gmail.com wrote:
|
No, just with cmake. Should I try? I am not sure how to go about... Create a xcode project file with cmake and then compile within XCode? |
Still, with cmake it shouldn't make much difference.... maybe on 10.6 the On Tue, Oct 7, 2014 at 10:18 AM, Rainer Schütz notifications@github.com
|
Checking now... |
it compiles, but it does not link ... apple likes to move around code among their frameworks ... maybe you
|
@bagong is there a way you can get the "verbose" compile output from cmake? AFAICT the foundation framework contains everything we need here, and has On Tue, Oct 7, 2014 at 10:32 AM, Tim Blechmann notifications@github.com
|
Yea, I can set verbosity up. I'm just updating macports. That link looked dead in the past, but they seem to have reactivated 10.6 support. I'll try to refresh the system and send the output of a verbose compile your way. Thanks for your support! Much appreciated! |
It took a while, sorry, came into trouble when trying to update via Macports. I switched to Homebrew, it seems to support 10.6 with universal builds well, now (and yes, purged MacPorts without trace :)). Unfortunately the error is still the same. This is the verbose output:
|
Can you run: -Seth On Tue, Oct 7, 2014 at 5:09 PM, Rainer Schütz notifications@github.com
|
I just checked XCode and found that I could download (and update) Mac OSX 10.6 core library and developer library. Might that contain the missing symbols? It'll be done in 10 mins, I'll tell you if it changes anything... |
No, still the same error... I'll try with an XCode-Generator now... |
I think I'm on to the problem, hold on a sec.... On Tue, Oct 7, 2014 at 5:31 PM, Rainer Schütz notifications@github.com
|
Okay, great! |
OK, try running this command:
This is exactly the command your cmake is running to link, but with "-framework Foundation" tacked to the end. If this works, the next question is why "-framework Foundation" isn't making it into the link command. |
Hm, not sure if I understood what I should do, but something changed:
It went right past that point quite a while, but then broke here:
|
Is this a clean checkout? Its weird that the "-framework Foundation" wasn't -Seth On Tue, Oct 7, 2014 at 5:52 PM, Rainer Schütz notifications@github.com
|
Are you referring to CMakeList.txt in servers/scsynth? |
Okay, it is not in 3.6, I'll add it. As to the SC_TerminalClient error, I'll check on readline. Maybe after all homebrew does not provide a universal binary. I'll let you know, if you're still willing to listen :) |
|
@Snickel, I am pretty sure my problem is where (or if) to put the
in the old SC_Terminal_Client.cpp. It differs substantially from the one in the 3.7 branch. There is no Could you spare a minute to have a look? It's here: https://github.com/supercollider/supercollider/blob/3.6/lang/LangSource/SC_TerminalClient.cpp |
On a more general line: There is a current thread on SC-Users where Arthur Sauer describes pretty frustrating experiences after force moving to 10.9 with a given project developed in 3.6.6. Seems likely this is AppNap-related although his findings are not unambiguous yet: I have invited him to this thread. Hopefully he can provide some real world experiences. His findings (nested in two ifs) would mean there is another process affected by AppNap that might be relevant when communicating with SC from another Application (where all of SC goes to the background). |
This PR should disable appnap for supercollider processes (in paritcular: QtCollider, sclang & scsynth) on OS X 10.9. It will also inform OS X that we require high-quality-and-frequency timers.
NOTE: to compile this PR, you'll need to first apply PR #994 , which fixes compilation against the 10.9 SDK.