If you are using Spotlight as a Finder search replacement, you've seen that is fast, but not fast enough. To optimize Spotlight search times, I've tried to renice the process that's behind the searches. Looking at the CPU usage in the Terminal (via top -o cpu) during searches, I've seen that a process named mds is the one that does it all. Using an AppleScript to renice the mds process, we can cut research times even at half.
Here's the script:
tell application "Terminal"
do shell script ¬
"sudo renice -20 -p `ps -axww | grep '[/]mds'| awk '{print $1}'`"
quit "terminal"
end tell
Save the script as an application, and using the Login Items tab of the Accounts System Preferences panel, list it as a startup file. Now you have to logout and re-login. You'll se a Terminal window appear and disappear soon after. To check if the renice command has been successful, you can open the Terminal and type:
ps -axww -l nice | grep '[/]mds'
and check if the sixth field is -20.
The renice command has to be given as "root," and to have it work without giving an admin password every time, you have to modify the /etc/sudoers file. To do that, open the Terminal and type:
sudo visudo
At some place in the file, add the following line:
%admin ALL = NOPASSWD: /usr/bin/renice
That let's any admin users run the renice command without giving their admin passwords. Save and that's done.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050502104827684