If your fans are kicking in and your battery life are going down because of the “mds” and “mdsworker” tasks then read on…
These two tasks are Spotlight indexing and if they keep going for a long time (and you haven’t just reinstalled the OS or dumped a lot of files on your HD) then there is probably something wrong. In my case “mds” kept indexing the Backblaze filelists, and since Backblaze per default monitors the filesystem continuously it would never stop.
I ended up adding /Library/Backblaze to the privacy settings in Spotlight preferences but it is more interesting to find out how I identified the problem. I opened a terminal window and wrote the following:
$ sudo dtrace -s /dev/stdin
syscall::open*:entry
{
printf("%s %s", execname, copyinstr(arg0));
}
^D
The “^D” is Control+D and remember the line break after the last curly brace. (See a tutorial about DTrace here).
This will churn out a list of all the files that are being accessed on your system in (almost) real time. Look for lines with “mds” or “mdsworker” in them. There you can see what files are being accessed by the Spotlight indexer. If the same files are being indexed again and again you have found the problem. Otherwise just follow what is going on and see if you can identify why the indexer never finishes. At least now you can see what is going on.