ATSServer and mdworker consuming significantly huge amount of CPU resources

My Mac have 4-core 3.0 GHz CPU with 4 GB RAM, yet this past week or so it seems to slow down to a crawl. Switching applications become sluggish, Dashboard taking its own sweet time to appear, and the CPU meter is constantly showing 100% usage in two of the core.

After some investigation, turns out that the offending processes are ATSServer and mdworker. ATSServer is Apple Type Solution Server, basically responsible for managing fonts and making them available to applications. mdworker meanwhile is part of Spotlight which is responsible to index files in your system. How can the two be related?

Well, poking around with Activity Monitor (using "Open Files and Ports"), it shows that mdworker is busily accessing my collection of PDF ebooks, which I recently copied to my home folder from my external disks. Also, it shows that fonts files are also being opened by mdworker when this indexing occurs. Voila!

So I opened up System Preferences -> Spotlight, and under Privacy tab, I added the ebooks directory. This tells Spotlight not to index my massive PDF collections. After 2-3 minutes, my processor utilization magically drops down to 1%-2%. Go figure.

This of course is just a workaround. Spotlight can't search folders you have excluded, obviously. But I need my CPU for my video conversion tasks right now. Ebooks indexing can happen later. I believe if I waited patiently enough, Spotlight will eventually finish the indexing, and the processor utilization will go down eventually.

Another way is basically to renice ATSServer and mdworker, using renice 20 -p pid_of_ATSServer and renice 20 -p pid_of_mdworker. But you'll have to do this every time you login / reboot / shutdown, and new instance of ATSServer and mdworker will always have nice level 0. After changing manually for a while, it will become tedious...