DirectoryService high CPU utilization

Jul 14, '10 07:30:00AM

Contributed by: tache

I had been experiencing extremely high CPU utilization by the DirectoryService process. Most of the time it was at 65% CPU usage, and sometimes it was up to 190%.

I traced this to my usage of the /etc/hosts file (with 16K+ entries) to combat website ads. Each entry in the /etc/host file had the form: 127.0.0.1 <hostname>.

Here is an alternative method of host redirection that reduces the CPU burden of DirectoryService to nearly nothing. Dnsmasq is a small footprint DNS/DHCP server designed for small networks, or is this case, a single machine.

The efficient dnsmasq process does not even register any percentage, sticking at 0.0%. Afterwards, DirectoryService CPU utilization now sits at 0.0%.

[crarko adds: I haven't tested this one. There obviously are browser specific adblockers but the use of the hosts file is a time-honored method of address redirection. There is further explanation of how to use dnsmasq and some examples in this article.]

Comments (19)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100713190059936