[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Net::HTTP Performance....

Ola Bini

7/17/2006 8:20:00 AM

Ben Johnson wrote:
> I know there was already another thread on this, but I didn't completely
> understand. I would love to re-read it but I accidentally deleted the
> emails. I remember something about changing a buffer size.
>
> Can anyone please send me that thread or basically tell me what the fix
> was, because I could desperately use it.
>
> Also, I'm not 100% sure this fix would apply to my situation, but
> basically I'm going out to a website and retrieving the HTML. Is that
> fix applicable here and would it improve speed?
>
> Thanks for your help.
>
> Thank You,
> Ben Johnson
> E: bjohnson@contuitive.com
>
>
>
>

Yes, and yes. The fix is basically to go into your
$RUBY_HOME/lib/ruby/1.8/net/protocol.rb, find the method called
rbuf_fill and change the sysread to something bigger than 1024. Probably
8192 or 16384 would be good enough for your purposes.


--
Ola Bini (http://ola-bini.bl...)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http:/...)
OLogix Consulting (http://www....)

"Yields falsehood when quined" yields falsehood when quined.



1 Answer

Florian Frank

7/17/2006 8:39:00 AM

0

Ola Bini wrote:

> Yes, and yes. The fix is basically to go into your
> $RUBY_HOME/lib/ruby/1.8/net/protocol.rb, find the method called
> rbuf_fill and change the sysread to something bigger than 1024.
> Probably 8192 or 16384 would be good enough for your purposes.

Ruby being Ruby, you can also just reopen the class and redefine the
method in question to your liking:

class ::Net::BufferedIO
def rbuf_fill
timeout(@read_timeout) {
@rbuf << @io.sysread(8192)
}
end
end

But it's probably not a good idea to release code like this in a library
to the public.