Tom went ahead and applied this patch last night, so I just gave it a whirl. It definitely appears to be working well.

[EMAIL PROTECTED]:~/workspace/jruby$ time gem install --version=1.1.2 rails --include-dependencies --no-rdoc
...
real    0m47.541s
user    0m30.322s
sys     0m3.336s

On this same system Ruby installs all the Rails stuff in about 16 seconds.

On 6/27/06, Evan Buswell <[EMAIL PROTECTED]> wrote:
Yep.  I've tested this with net/http which was blocking forever before -- now it downloads as fast as it ought.

Evan

On 6/27/06, Evan Buswell < [EMAIL PROTECTED]> wrote:
Yeah, about 2 minutes after I sent that I realized that was your change and it had reason for being there.  Sorry.

The problem isn't the blocking channel, its my sysread function.

Here's the deal: I was under the impression sysread(20) meant block till you read 20, otherwise what distinguishes it from recv?  But no, some testing with ruby confirms: with both a normal blocking socket and pipe, sysread(20) will return up to 20 bytes of whatever data is available.  So the net/http sysread(1024) was blocking until it read *1024* bytes; not 20 bytes.

I know exactly how to fix this so a new patch should be along shortly to replace the fcntl patch I just sent.


Evan

On 6/27/06, Charles O Nutter <[EMAIL PROTECTED] > wrote:
The Selectable nonblocking thing was my contribution to fix the fact that sockets were blocking by default. This caused a final read from the socket to block until Ruby's timeout.rb thread interrupted it, causing the gem exception that didn't seem to hurt anything. Setting the channel nonblocking fixed it and eliminated that last read waiting for timeout.

We'll have a look at the patch and give it a try with gems and rails and whatnot. I think we're pretty well set for 0.9.0, but if this is not too complicated and accomplishes what my nonblocking hack did, we may include it.

Thanks for the quick turnaround.


On 6/27/06, Evan Buswell < [EMAIL PROTECTED]> wrote:
Patch is attached.

I noticed that code somehow crept in to set selectable channels nonblocking by default (probably my fault).  This may be part of the problem with the exception being thrown at the end of the gem download.  This is also fixed in this patch.

The approach I took here is to have a blocking flag and defer setting the channel blocking if we can't.  If one thread is in the middle of a select() on a blocking socket and another thread is reading(), it'll "spin-block" until the data is read.  If a thread sets a previously non-blocking socket blocking during a select, the blocking flag will be set true, and at the end of the select the channel will be set blocking.

This isn't great, but its very close to being Right.  A lot of this multi-threading stuff doesn't make sense semantically, but you know...I get that itchy feeling on the back of my neck when I know something could theoretically blow up...

Evan


On 6/27/06, Charles O Nutter <[EMAIL PROTECTED] > wrote:
Sounds good on all points. We may or may not ship 0.9.0 with your updated patch (probably not) but we have seen no issues from my admittedly naive attempt. Get your patch over to us whenever you can, but don't worry about holding up the release.

On 6/27/06, Evan Buswell < [EMAIL PROTECTED]> wrote:
That's the problem.  AFAIK, C select() on which Ruby's is based makes no requirements about blocking/non-blocking, so this is only an issue in Java, where if we are doing a select(), the socket must be nonblocking, and if we set the socket blocking while in the middle of a select, an exception is thrown.

Aside from this issue, I noticed this patch only sets the socket non-blocking without changing the behavior of some of the functions.  Channel.read() is closer to recv(), so when we do sysread() or read(), we loop over Channel.read().  If the Channel is non-blocking, that means we just spin (this could maybe account for the 99% CPU that someone was mentioning?).

I'm going to try and write a patch that will configure non-blocking and avoid these issues.  Hopefully I'll have it later today.

Evan

On 6/16/06, Charles O Nutter < [EMAIL PROTECTED]> wrote:
Do whatever Ruby does :)


On 6/16/06, Evan Buswell < [EMAIL PROTECTED]> wrote:
I'm on vacation so I haven't had a chance to look at this patch.

Beware that there are issues with nonblocking io and select().  While a
SocketChannel is being select()ed, it *must* be in nonblocking mode.  I
was thinking about implementing fcntl for nonblocking io, but the
problem is what if while one thread is select()ing on a socket, another
sets the socket blocking?  Either we have to block the fcntl until the
select completes or we have to do some weird threading delay-set magic.

Granted there might not be one single instance of something like this
happening, but then again there might.

Evan

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com



_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel





--

Evan Buswell
[EMAIL PROTECTED]

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642



_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel





--

Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org

Application Architect @ www.ventera.com

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel





--
Evan Buswell
[EMAIL PROTECTED]

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel






--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org
Application Architect @ www.ventera.com

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel





--
Evan Buswell
[EMAIL PROTECTED]



--

Evan Buswell
[EMAIL PROTECTED]

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel






--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org
Application Architect @ www.ventera.com
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to