How do Run the Spotlight indexer at a lower priority to reduce CPU load on your Mac

From WeatherCat Wiki (Mahler)
(Difference between revisions)
Jump to: navigation, search
(Added a warning never to attempt this procedure on OS-10.9 Mavericks.)
m (fixed typo)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
'''Draft document!!'''
+
* 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.
* Do '''NOT''' follow this procedure until approved!
+
  
* 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.
+
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:
+
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:
  
 
* [http://newartisans.com/2008/04/run-the-spotlight-indexer-at-a-lower-priority/ Run the Spotlight indexer at a lower priority]
 
* [http://newartisans.com/2008/04/run-the-spotlight-indexer-at-a-lower-priority/ Run the Spotlight indexer at a lower priority]
Line 17: Line 16:
 
  /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
 
  /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  
One way to modify this file is to use a free property list editor called [http://www.nightproductions.net/prefsetter.html ''Pref Setter''].  If you have Apple's development environment installed than you can use the Xcode: ''Property List Editor''.  Either tool will work for this procedure.
+
One way to modify this file is to use a free property list editor called [http://www.nightproductions.net/prefsetter.html ''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.  Enter the following 3 commands one after the other:
+
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
 
  cd
Line 25: Line 24:
 
  cp /System/Library/LaunchDaemons/com.apple.metadata.mds.plist ~/Desktop
 
  cp /System/Library/LaunchDaemons/com.apple.metadata.mds.plist ~/Desktop
  
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.
+
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.  It will look something like this:
+
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:
  
 
[[File:Original com.apple.metadata.mds.plist.png]]
 
[[File:Original com.apple.metadata.mds.plist.png]]
  
You will now need to add two keys.  To do this use the gear menu at the top of ''Pref Setter'' application.  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.  When you are completed you should have something that looks like this in ''Pref Setter'':
+
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'':
  
 
[[File:Prefs Setter version of mds plist.png]]
 
[[File:Prefs Setter version of mds plist.png]]
Line 49: Line 48:
 
[[File:TextEdit version of com.apple.metadata.mds.plist.png]]
 
[[File:TextEdit version of com.apple.metadata.mds.plist.png]]
  
The order of the elements may vary, but the each part should be as they are shown.
+
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 your MacinotshInstalling the modified file can be done with this terminal command:
+
Once you are satisfied that you have a correctly modified file, you can install the file and restart the ''mds'' daemonThe 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 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.  Once this is done you can restart your Mac and you should see that the ''mds'' process uses less of your computer's resources.  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 terminal command above to move that version into the correct location. Once again, by rebooting you will return to the condition you were before making any modifications. 
+
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.
 
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.

Latest revision as of 06:11, 3 February 2014

  • 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:

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:

/System/Library/LaunchDaemons/com.apple.metadata.mds.plist

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:

Original com.apple.metadata.mds.plist.png

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:

Prefs Setter version of mds plist.png

Here is the same modified com.apple.metadata.mds.plist file as it appears in Apple's Property List Editor:

Xcode Property list editor.png

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:

open ~/com.apple.metadata.mds.plist

This will open a TextEdit window that should look something like this:

TextEdit version of com.apple.metadata.mds.plist.png

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.

Personal tools
Namespaces

Variants
Actions
Navigation
Tools