assertTrue is the professional blog of Luke Bayes and Ali Mills

Is RubyGems running really, really slow on OSX? How about 60 second delays for HTTP requests?

Posted by Luke Bayes Sun, 04 May 2008 21:36:00 GMT

Updated on June 23, 2008: There was just a release to RubyGems 1.2 yesterday and RubyGems is now blazing fast, no more index updates and who-knows-what-else every time you install a gem.

Ali and I ran into an interesting Ruby bug on OSX Leopard last week and I thought I’d share the result of our finding….

Basically, we were requesting a 2k RSS feed from a url that had two sub-domains as in:

http://sub1.sub2.example.com

The request worked fine if we hit the server with only one sub-domain as in:

http://sub2.example.com

In the first example, the request would hang for exactly 60 seconds and then return the result. When we tried with a third sub-domain, we got a 120 second hang and then an error.

After digging through the Ruby sources, it looked like the problem was in the TCPSocket C implementation so I threw an email up on the Ruby list.

Turns out the fix is that if you’re trying to use Ruby networking features that sit on top of TCP on OS X Leopard, you may need to add the following to your code:

require 'resolv-replace'

Found the fix in this thread.

I also added this line to /usr/lib/ruby/1.8/rubygems.rb (around line 11) and RubyGems is suddenly much, much faster.

Tags ,  | no comments

Comments

Your Reply

Comment Form.

Fields denoted with an "*" are required.