How to Run the Spotlight indexer at a lower priority to reduce CPU load on your Mac
- Do NOT attempt this procedure on OS 10.9 (Mavericks)! The mds daemon functions differently and cannot have its processing priority lowered. Attempting this procedure will only cause your computer to malfunction.
This procedure has been successfully applied to OS 10.8 (Mountain Lion), OS 10.7 (Lion), and OS 10.6 (Snow Leopard).
OS X has a built-in file content indexing system called Spotlight. This system relies upon a system daemon named mds. That daemon spawns in turn UNIX processes that run invisibly in the background to index files during the time your Macintosh is running. The mds daemon is supposed to accomplish this task in such a way as to not interfere with the operations of your computer. However, there are situations that can fool the mds daemon into assuming that indexing can be accomplished when it isn't the most convenient. For example, even if a computer is not being used, it may be in a bedroom and the CPU intensive task of indexing files could turn on the computers fans - potentially becoming a nuisance. Many users of WeatherCat run their computers 24/7; as a result, the evening and early morning hours provide ample time to accomplish the task of indexing a hard drive. In that case, it may be desirable to have the mds daemon work as slowly as it can be configured to.
Early in the existence of UNIX, a system to control the priority of running applications was added. This system under the UNIX command name: nice allows for CPU intensive applications to be given lower priority than applications requiring quick response. OS X continues to incorporate this feature and various users have found a way to "renice" the mds daemon to reduce its effect on your computer. Two possible ways to do this are described in these blog entries:
- Run the Spotlight indexer at a lower priority
- Is mdworker Jeopardizing Your Resources? Run It at a Lower Priority
The procedure below is a conservative composite of the two blog entries above. While there is nothing extremely dangerous in following this procedure, it is modifying your system. Therefore extra caution is advised. System backups are always recommended beyond the backup proposed in this procedure.
What is required is to modify a file in your system called: com.apple.metadata.mds.plist. The complete UNIX path to this file is:
One way to modify this file is to use a free property list editor called Pref Setter. If you have Apple's development environment installed then you can use the Xcode: Property List Editor. Either tool will work for this procedure, although if you are familiar with the Apple development tools, the Property List Editor is more straightforward to use.
To start, you should make two copies of the com.apple.metadata.mds.plist file - one to modify and one as a backup in case you run into a problem. To do this, you will need to use the Terminal application which you'll find in the Utilities folder (inside the Applications folder.) Enter the following 3 commands one after the other:
cd cp /System/Library/LaunchDaemons/com.apple.metadata.mds.plist ~ cp /System/Library/LaunchDaemons/com.apple.metadata.mds.plist ~/Desktop
The second command will put a copy of the com.apple.metadata.mds.plist in your home folder. This is the copy of the file you will edit. The last command will put a copy of the com.apple.metadata.mds.plist file on your desktop so you may move it to any safe place as your backup version.
Now launch either Pref Setter or Property List Editor and open the copy of the com.apple.metadata.mds.plist in your home folder. Unfortunately, Pref Setter is designed to "save yourself" from damaging your system by refusing to edit any file outside of your preference folder if installed as a regular application. Fortunately, there is an easy to defeat this protection. If you launch Pref Setter from another place on your hard drive (like your desktop) you can then edit any preference file. It will look something like this:
You will now need to add two keys. To do this use the gear menu at the top of Pref Setter application. When using Pref Setter, be careful to have nothing selected in the preferences before creating a new key; otherwise it will add your keys into the selection which isn't what you want. One way to avoid this is to click on the empty space underneath the keys that are displayed. That will deselect the first key which is what is displayed when the program first starts. The first new key you need to create has the name: LowPriorityIO. Keys are like computer language variable types. They hold a type of data and then are set to a particular value. The key LowPriorityIO is a boolean type key and it should have the value of true. The second key you need to create has the name Nice and is of type integer. You need to set this key to the value 20. The best procedure for creating these keys is to and paste the text from this narrative. Everything matters including the capitals, so be very careful in copying the key names. If you make a mistake with Pref Setter, you can always revert to the original version and start over. When you are completed you should have something that looks like this in Pref Setter:
Here is the same modified com.apple.metadata.mds.plist file as it appears in Apple's Property List Editor:
Once you are satisfied that you have correctly made these modifications, save the modified file.
Now as a precaution, run the following command in your terminal session:
This will open a TextEdit window that should look something like this:
In some cases, the file will open once more in the application you used to make the modifications like Pref Setter. If that happens, you can launch TextEdit first and then open the com.apple.metadata.mds.plist from within TextEdit. The order of the elements may vary, and your file may either contain additional information or otherwise vary from this example, based on your version of OS X, but you should see the new keys you added exactly as they are shown above.
Once you are satisfied that you have a correctly modified file, you can install the file and restart the mds daemon. The safest procedure is to stop the mds daemon, move the modified preference file into place, and then start up the mds daemon once more. The following four UNIX commands accomplish this procedure.
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist sudo mv ~/com.apple.metadata.mds.plist /System/Library/LaunchDaemons/com.apple.metadata.mds.plist sudo chown root:wheel /System/Library/LaunchDaemons/com.apple.metadata.mds.plist sudo launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
You will be asked to supply your Mac administrator's password after the first command. The first and last commands stop and start the daemon. The second command actually moves your modified file into place, and the third command changes the file ownership's as required by OS X. Once this is done, you should see that the mds process uses less of your computer's resources. Once you have determined that your modified file is properly working, you can delete the copy of the original file from your desktop
Should you have any problems, copy the backup copy of the com.apple.metadata.mds.plist that you had kept to your home folder and once more use the 4 terminal commands above to move that version into the correct location.
As noted this procedure requires meticulous precision. However, if you follow this procedure to the letter, you shouldn't have any difficulties with this modification.