#1162: Slowdown due to gethostbyname --------------------+------------------------------------------------------- Reporter: hinder | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: Cactus | Version: Keywords: | --------------------+------------------------------------------------------- When running the ET testsuite on my laptop, I found it was taking 7 minutes to run just the tests from the McLachlan arrangement. The CPU usage was negligible for much of the time. I noticed that when running an empty parameter file, there was a slowdown before printing the host name. Additionally, when I attached a debugger to find out why cactus was taking so long to run the tests, the backtrace showed:
{{{ 0x00007fff90f0dd16 in kevent () (gdb) bt #0 0x00007fff90f0dd16 in kevent () #1 0x00007fff954c390a in _mdns_search () #2 0x00007fff954c3345 in mdns_hostbyname () #3 0x00007fff954c31c1 in search_host_byname () #4 0x00007fff954c30c1 in gethostbyname () #5 0x00000001096becf8 in Util_GetHostName (name=0x7fff56551550 "macbook", length=255) at Network.c:86 }}}
Util_GetHostName first calls gethostname, and if that function returns something with no "." in it, it calls gethostbyname. Indeed, my local hostname does not have a "." in it.
This is on Mac OS 10.8.2. Changing the hostname via
{{{ sudo scutil --set HostName Ians-MacBook-Pro.local }}}
so the hostname included a ".", the tests now run in 1m30s. I don't know why gethostbyname is so slow on my system. Does Cactus, or maybe simfactory, or maybe the test system, call gethostbyname very frequently? Perhaps the output could be cached if this call can sometimes be slow.