Project

General

Profile

Actions

Bug #496

closed

DRb.start_service(nil) is very slow

Added by hongli (Hongli Lai) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-core:18381]

Description

=begin
On some systems - such as mine - DRB.start_service(nil) is very slow. This is caused by the fact that DRb.open_server calls TCPServer.open(nil, 0).addr[1]. On my system, this takes about 3 seconds, and during those 3 seconds there is 0% CPU usage.

I suspect it has got something to do with the fact that retrieving the port of a server socket that's bound to 0.0.0.0 is for some unknown reason very slow.

The problem can be fixed by replacing the following line in drb.rb

uri = 'druby://:0' unless uri

with:

uri = 'druby://localhost:0' unless uri

This does not violate DRb.start_service's contract, because a nil indicates that it will bind to the default local host name.

The following monkeypatch works around the issue:

module DRb
class << self
alias orig_start_service start_service
end

 def self.start_service(uri = nil, front = nil, config = nil)
   if uri.nil?
     orig_start_service("druby://localhost:0", front, config)
   else
     orig_start_service(uri, front, config)
   end
 end

end
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #1811: Default BasicSocket.do_not_reverse_lookup to trueClosednobu (Nobuyoshi Nakada)07/23/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0