One of the most common and biggest trade-offs to higher performance is time; that is, the time it takes to complete a task is typically disproportional to the amount of processing resources allocated to said task or application. The higher the CPU priority usually the faster the task will complete, and the converse to this applies as well.
Computers process data—simply put, it's what they do. And while modern operating systems and their applications perform this feat efficiently, users can further manage how CPUs process data by controlling how these resources are allocated to apps or, at a granular level, to individual threads.
SEE: Virtualization policy (Tech Pro Research)
MacOS' UNIX foundation allows users to benefit from these performance tweaks by adjusting the "niceness" assigned to a task or application using the Terminal. This is achieved with the nice and renice commands, as they report back the current level of niceness assigned and allow for reconfiguration of the niceness on a scale of 20 (lowest priority) to -20 (highest priority), respectively.
In the examples below, I'll cover how to identify the current niceness level, how to adjust it for a thread, and how to launch an app with the desired level of niceness.
SEE: Top 20 Apple keyboard shortcuts for business users (free PDF) (TechRepublic)
How to identify the priority of a running app
1. Launch the Terminal.
2. Enter the following command to display the current processes running on the computer.
3. Depending on the number of processes currently running, the list could be quite long. Another method of identifying a particular app is by launching the Application Monitor to locate its PID value. Armed with the PID, we can proceed with finding out the NICE level, by entering the command below.
ps -fl -C PID
The output will display many details relevant to the running process; however, the priority level assigned will be located under the NI column and will be an integer, as seen below.
THEMACJESUS:~ jesus$ ps -fl -C 15034 UID PID PPID C STIME TTY TIME CMD F PRI NI SZ RSS WCHAN S ADDR 501 15034 1 0 Wed05PM ?? 2:55.13 /Applications/Pa 1004084 46 0 2899316 103484 - S 0
How to change the priority of a running app
1. At the Terminal, enter the following command referencing the application's PID to increase or decrease the priority. Note: The scale ranges from -20 to 20; the lower the value, the higher of a priority the task will be given.
renice -n "value" -p PID
To verify, rerun the PS command above from step 3 to confirm the change in priority.
THEMACJESUS:~ jesus$ ps -fl -C 15034 UID PID PPID C STIME TTY TIME CMD F PRI NI SZ RSS WCHAN S ADDR 501 15034 1 0 Wed05PM ?? 3:36.20 /Applications/Pa 1004084 46 -1 2931808 129564 - S< 0
How to launch an app with a high priority
1. At the Terminal, enter the following command referencing the path to the application in order to launch it with the highest priority available.
sudo nice -1 "/Path/to/Application/Contents/MacOS/ApplicationName"
Rerunning the PS command will verify the priority or Niceness (NI) level. If entering a negative value, such as -10, use the double hypen (—) to delineate between positive and negative values.
THEMACJESUS:~ jesus$ ps -fl -C 24894 UID PID PPID C STIME TTY TIME CMD F PRI NI SZ RSS WCHAN S ADDR 501 24894 15071 0 12:26PM ttys000 0:03.23 /Applications/Ke 4006 4 1 2884276 212452 - SN+ 0
- Apple: You need to do much better in 2018 (ZDNet)
- 16 Terminal commands every user should know (TechRepublic)
- Mac Terminal basics: Unlock the power of the command line (TechRepublic)
- Interview form: Support professional (Tech Pro Research)
How often do you manage CPU thresholds for running processes, applications, and services? What methods (other than the ones stated above) help you to achieve maximum efficiency? We'd love to hear from you below in the comments section.
Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from several vendors, including Apple and CompTIA.