Hi

I recently had to deal with the performance of downloads in Buildr. What I found is that Ruby's HTTP implementation used a fixed size for the buffer size it used of 1024 bytes. This size creates means more calls to the OS and so hurts performance.


The workaround I used is:

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


It seems to decrease download time by half.


HTH,

Ittay


Reply via email to