Increasing Ruby's Net::BufferedIO buffer size
Reading bytes from Net::HTTP seems really slow, around 1Mb/s for a close host. Not many people seem to have complained about this, but I found some insight from Headius and monkey-patched Net::BufferedIO::rbuf_fill. Changing the read buffer size from 1k to 32k brought the throughput up to 24Mb/s.
module Net
class BufferedIO
def rbuf_fill
timeout(@read_timeout) { @rbuf << @io.sysread(32768) }
end
end
end
Labels: ruby
1 Comments:
This is awesome. Just what I needed. Thanks!
Post a Comment
<< Home