Why is Illustrator throttled to 2% speed when it's in the background?
I regularly run a .jsx script in Adobe Illustrator that saves a bunch of files in a particular format.
while Illustrator is the active app, running the script on 5 files takes 23 seconds.
When Illustrator is not the foremost app, running the script on 5 files takes more than 5 minutes.
According to Activity Monitor, Illustrator is using around 75% of the CPU when in the foreground but is throttled to less than 2% when in the background.
According to Activity Monitor, App Nap is not being used.
Why is this happening, and is there a way to change it?
I would like to be able to do other tasks while waiting for Illustrator. As it stands, I am obliged to keep Illustrator in the foreground.
Some things I have tried: I knew that
sudo sysctl debug.lowpri_throttle_enabled=0
worked to accelerate Time Machine backups, so I though it might help in this case. It had no effect.
I also tried disabling App Nap:
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
It had no effect.
I tried TinkerTool, but I believe that it's just a GUI to change the lowpri_throttle_enabled setting. It had no effect.
Solution 1:
This appears to be be an Adobe issue; specifically, the code-base for AI is not multi-threaded.
I was able to find a discussion in the Adobe forums that addresses your exact issue - Make Illustrator multi threaded on CPU
Illustrator performance is awful, its slow and lumbering at all but the most basic operations. It is bound to only a single cpu thread which is ridiculous now in an age of multi core and multi thread CPU's and it has been this way for many years. It cannot handle background tasks and is completely out of parity in function and performance with other Adobe software such as Photoshop and inDesign.
Emphasis mine
Unfortunately, if the code cannot support background CPU operations, there's nothing you can do from your Mac's perspective to speed things up. As the users in the forum all (begrudgingly) accept, the only solution is to wait for an update from Adobe.
Why this is so
Generally speaking, applications in the background are "paused" - technically, they are given low priority. What this means is that execution stops until the CPU has an opportunity to execute some more commands; usually during an IO fetch operation. Managing this process is called "CPU Scheduling" and is something the hardware handles for you - the application just has to allow it (relinquish control).
A common misconception of multi-threading is that things execute faster. This is not the case, it's just more things happen simultaneously making better use of the CPU resources. It's like having a single taxi (people carrier) shuttling people between an airport and a conference center versus four doing the shuttling. They're all going the same speed, it's just now you're moving more.
The application being "multi-thread capable" allows the hardware to manage and schedule CPU time and being that there's more CPU that can be allocated, the background jobs get more resources to get the job done.