I made a MacOS app that does a long calculation (a theoretical simulation) in a large number of GCD background threads. The calculation can take many hours and periodically updates the application's window to show intermediate results.
Performance is great as long as the application's window is visible: all cores at 100%, ventilator fan full blast, while the system remains completely responsive in other apps. I can still browse the web, watch videos, etcetera, but all excess power goes to the background threads which is great.
However, as soon as I completely cover my app's windows, performance drops to something like 30% and I can hear the fan slow down and even turn completely off. The same thing happens if I lock the screen (when I want to leave the computer unattended while the calculation is running).
What can I do to keep the computer from throttling down? I don't want to give the background threads real time priority because I want my computer to remain usable, but I do want to keep the computer as a whole at maximum power. Right now I try to keep a tiny corner of the app visible at all times, but there has to be a better way.
I'm using Grand Central Dispatch for the threads, so I hope there's a simple solution without requiring explicit thread management.
Thanks for any info!
Michel