Tuesday, June 14, 2011

A Tip for Improving System Performance on Older Mac/Linux Machines

If you have an older, resource-deprived machine running Mac OSX or any Linux variant, here is a useful tip to improve system "load-balancing" and stability.

Firstly, determine what you want to accomplish... for the sake of this example, let's say that your music player becomes choppy while performing certain CPU intensive tasks.

Step 1) Open a Terminal window and type "top"
(This will display a task manager that shows all running processes and their associated resource-usage)

Step 2) Find the process that you are interested in changing, in our case, iTunes and take note of the number next to that process in the PID column, this is the process ID for that particular application. In our case the PID is 187, but this will be different on every computer and every time a process is restarted, it will be assigned a new PID.

Step 3) Hit Ctrl+Z to stop TOP and bring you back to your terminal prompt.

Step 4) Use the "renice" command to alter the CPU scheduler priority of that process.

The renice command takes an integer value between -19 (highest priority) and 19 (lowest priority). We call this value, the "niceness".

The niceness that we set for a particular process is specific to our goals. In our example, choppy iTunes, we might want to set the niceness to -10

Note: The niceness of a process can be set to positive number integer values (lower priority) without the need for elevated privileges, however, to set niceness to a negative integer (higher priority), you will need to provide the superuser password.

So, the appropriate command for our specific example would be:

sudo renice -10 -p 187

Explanation of the command:

sudo - Runs the command as SuperUser, so it will ask for the root password once you hit enter. This part of the command is not necessary if you are setting niceness to a positive value.

renice - The command to change CPU scheduler priority

-10 - The niceness we chose to set this process to.

-p - The command switch that tells renice that we will be giving it the process ID.

187 - The process ID that we got from TOP.

This very simple, very old command line utility has a near infinite number of uses, so.. Have Fun!

If you think this is cool and would like to very easily wield this level of control over your Android powered device, check out my app, Mr. Nice Guy on the Android Market:

Mr. Nice Guy

No comments:

Post a Comment