Webrick socket.readline causes 100% cpu usage
---------------------------------------------
Key: JRUBY-5122
URL: http://jira.codehaus.org/browse/JRUBY-5122
Project: JRuby
Issue Type: Bug
Components: Performance
Affects Versions: JRuby 1.5.3
Environment: MacOSX 10.6.4 (Java HotSpot(TM) 64-Bit Server VM
1.6.0_20) [x86_64-java]
Reporter: Vanja Bucic
Priority: Critical
Fix For: JRuby 1.5.3
socket.readline/gets causes 100% cpu usage per handling thread (client socket)
when using Webrick (did not try raw sockets, but I expect the same result).
Looks like some crazy selector loop.
Test case is small, so I am providing it inline. Each time you telnet/open a
connection to this server cpu usage will jump by 100%
This behavior is not only different that MRI but is plainly unusable.
#--------------------------------------------------------------------------------
require 'webrick'
require 'thread'
module Aggregator
class TestSocketServer < WEBrick::GenericServer
# ---------------------
def initialize(port)
@port = port
super(:Port => port)
end
# ---------------------
def begin_listening
Thread.new() {
self.start
}
end
# Called by WEBrick ---
def run(sock)
begin
aLine = sock.readline
p "[RECVD] #{aLine}"
rescue EOFError =>err
$stderr.puts("[#{self.class.name}]: #{err.class.name}: #{err.to_s}")
rescue => err
$stderr.puts("[#{self.class.name}]: #{err.class.name}: #{err.to_s}")
end
end
end
end
srvr = Aggregator::TestSocketServer.new(5555)
srvr.begin_listening
sleep 60
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email