Thursday, 24 January 2008

The Longest Journey

The problem

Running all the tests for our rails app took around 2 minutes on other machines and over 15 on mine.

The solution

Remove all network locations from System Preferences and put them back again.

The journey

I reduced the problem to a single test case with a single test method with a single line. Having no idea how exactly Rails Does Stuff, I ended up putting parts of debug output and tracing rails' inner paths this way. I got to before_filters, then spotted the filter that caused the problem - it was the "black-list" check (provided by a plugin). Obviously, it was a single line of the file: the url resolution.

Now, I was scared - it couldn't be ruby's fault! Fortunately, it wasn't: analogous python library was slow as well. Actually they didn't work at all. Even pinging a non-existent url took 7secs, and on ALL other machines (running various OS's) it took an instant. The guys from #ruby channel at freenode were helping me for around 2 hours (thanks a lot!), but still nothing seemed to fix the problem. I got pretty convinced, however, that my problem was caused by a bug in Leopard's TCP/IP implementation. Feeling a bit more firmly in the topic, I started searching in forums. And there it was: on the ruby forum. I followed the most crazy tip and found out why it was the last message in the thread.

P.S. Blogger provides an OpenID for its users! My way of celebrating the fact was signing up on (great site btw!)
P.S.2 Ola Bini run recently into the same problem, and put some more knowledge and investigation in solving it.

No comments: