Spotlight is a Let me love and hate things, on the one hand he really quite good, but on the other hand, he did occupy a lot of system resources, in a large number of file operations, often the CPU occupied, can be my poor mbp burned to about 80 degrees, So can not be a good toss him, here to summarize some of these two days to find out the spotlight tuning method, I hope to have some help for everyone. The following optimizations are practiced on Mac OS X Lion 10.7.2 Systems, and other versions of the system may have some different, but the basic steps should be the same. small Apple use Mac now total time is not more than a week, so a lot of things may be wrong to understand (what may ah, it should be), there is not the right place, but also please make a lot of corrections, also welcome everyone to my blog a lot of exchanges: http://bigasp.com/.
Spotlight Introduction
Spotlight is a search service in Mac system, in order to make the search more rapid, the MAC system will run an Indexing service in the background, in the case of file operations or data updates, such as Itunes,mail, will create an index for them, Used to speed up spotlight lookups. So, spotlight is actually divided into two parts: the foreground Spotlight Lookup service Search.bundle, and the backend Indexing Service MDS. optimization of the spotlight, in fact, is to optimize the two services.
Basic Optimization scenarios: reduce the content that needs to be indexed
according to the above introduction, we can think that the simplest optimization is to reduce the content that needs to be indexed.
First, select the content we need to index in the spotlight settings. Open System Preferences-> Spotlight, in the Search Results tab bar, we have all the content we don't care about all checked out. I only checked: apps, System Preferences, contacts and music. That's enough for me.
then, add the spotlight blacklist to the folders that we do not need to index. in System Preferences-> Spotlight In the Privacy tab, we can choose those directories are spotlight not to index, we can use this directory to greatly reduce the amount of files we need to index. Open Finder, click on the menu to go to-> to the folder, go to the root directory/, the folder in addition to the application and the user's directory, all blacklisted.
Note that: In fact, the user directory can also be blacklisted, spotlight display of music, contacts and mail, in fact, and these software databases directly linked to the index, so and the index of the folder is not too much contact, can also be blacklisted. Here to see everyone's preferences, I put it all in.
It is also important to note that there is a need to display all hidden files in the Finder, because some of the system-related directories, such as/usr, are not necessarily indexed, and can be blacklisted. If the way to display the file will not be, you can go to Google a bit.
Finally, we also need to set up the spotlight need to index the hard disk, some of the mobile hard disk and USB stick, in fact, do not need to index. Open the terminal and enter the following command:
- # Close Indexing Service for all disks
- sudo mdutil-a-I off
- # only open the primary hard disk Indexing Service, my primary hard drive is mounted to the/volumes/macintosh HD directory (the default setting), you can modify it according to the specific situation.
- sudo mdutil-i on "/volumes/macintosh hd"
Copy Code
If the above instruction executes an error, you can use the following command to restore the index of all disks.
- sudo mdutil-a-I. On
Copy Code
Well, by this we have completed the first step of optimization. At this point you can see that spotlight is rebuilding the index, and on my machine, it takes 2 hours to fully build an index, now it only takes a few minutes.
Replacement optimization Scenario I: Replacing the front-end portion of a spotlight
OK, after completing the basic optimization program, since we have spotlight castrated into this field. Let's just replace the spotlight with other software instead. Here's a nice free software recommendation: Alfred. You can search the App store directly in the installation, the process will not be described.
hide the spotlight icon in the taskbar The crux of the problem is: since spotlight is not needed, we do not need to show it. the way to close it is simple, enter the following command in the terminal:
- sudo mv/system/library/coreservices/search.bundle/system/library/coreservices/search2.bundle
- PS aux | grep Systemuiserver | Grep-v grep | Awk & #39; {print $2}& #39; | Xargs Kill
Copy Code
now we will find that the spotlight icon on the desktop is missing, and this step of optimization is declared complete.
of course, it is easy to restore, and you can restore it by entering the following command:
- sudo mv/system/library/coreservices/search2.bundle/system/library/coreservices/search.bundle
- PS aux | grep Systemuiserver | Grep-v grep | Awk & #39; {print $2}& #39; | Xargs Kill
Copy Code
Replace the optimization scheme II: Replace the entire Spotlight
stopping spotlight completely means not just shutting down Spotlight's desktop search, but also stopping the spotlight backend Indexing Service. So friendship reminds: there are monsters ahead! After spotlight is turned off, software that relies on Spotlight Indexing Service will not function properly, such as Alfred will not be able to display search results (dependent on the Spotlight Indexing Service MDS), please handle it carefully, if the problem is caused by a strange, not related to the author.
This scheme is my temporary favorite, because in the system Spotlight Indexing Service is still running at any time, so it will still occupy our system resources, and we have no control, completely replace him, is our best choice. OK, let's get started.
Stop Spotlight Background Index completely after completing the replacement optimization scenario I, we can enter the following command to completely stop the spotlight index.
-
- sudo launchctl unload-w/system/library/launchdaemons/com.apple.metadata.mds.plist
-
Copy Code
after entering this instruction, you can see if there are any MDS and mdsworker processes in the current system. They should all quit. at this point, spotlight is basically we have to kill.
of course, if we regret it, we can also recover it by the following command.
-
- sudo launchctl load-w/system/library/launchdaemons/com.apple.metadata.mds.plist
-
Copy Code after the recovery is complete, do not forget to check the contents of the basic optimization scheme, because indexing is stopped after the backend Indexing Service is stopped.
Installing alternative Software in the absence of a background Indexing service, can we still enjoy the same functionality as spotlight? a small software is recommended here: Launchy. Download page: HTTP://WWW.LAUNCHY.NET/DOWNLOAD.PHP#OSX, I installed the 2.6 Beta 2 version. This software will build its own index, although in terms of functionality, not as strong as Alfred, but it is also very similar to the image, the index of the video is necessary, personal reservations, reasons I believe we all understand, so basically for me is enough. in this software, we can set the index range of the software itself, or forbid it to update the index automatically, so that we can control the background service to the maximum extent.
Summary
so far, the optimization of the whole spotlight is complete, my poor MBP temperature is finally lowered, and will not cause the temperature spike because of the large number of file operations. In general, tossing or some effect, I hope to have some help for you.
=================== Gorgeous split-line ===================
2012-02-12 Supplement 1. Launchy 2.6 Beta and 2.5 appear to be frequently crash on some machines, and you can use Quicksilver (http://www.blacktree.com/) or search for other software yourself instead, as long as it's self-indexed. 2. In fact, if there is not a large number of file operations, the impact of spotlight on the system is not big, MDS occupied CPU is generally about 3%-5%, there is not much need to optimize. But if you find that the recent computer temperature is very high, or battery consumption is very fast, you can check the spotlight, the reference to this article is optimized. |