summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 23:52:08 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 23:52:08 +0000
commit8623ba8618ad3fce642b5d206626a3b39bf11139 (patch)
tree3676ac855fade1c5daf92e795cfe1618aa63e410 /tool
parent7406d7cffaef9664c32904ee9670d2fd5948efc8 (diff)
lib/net/protocol: clear short-lived read buffer
Using a parallel Net::HTTP downloader, this reduced memory usage from around 120MB to 50MB on my 32-bit x86 system. * lib/net/protocol.rb (rbuf_fill): clear temporary buffer Test script I used: require 'net/http' require 'uri' require 'digest/sha1' url = 'http://80x24.org/git-i-forgot-to-pack/objects/pack/pack-97b25a76c03b489d4cbbd85b12d0e1ad28717e55.idx' uri = URI(url) use_ssl = "https" == uri.scheme thrs = 30.times.map do Thread.start do cur = Thread.current.object_id Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http| req = Net::HTTP::Get.new(uri) http.request(req) do |res| dig = Digest::SHA1.new res.read_body do |buf| dig.update(buf) #buf.clear # most Ruby programmers don't do this :< end warn "#{Time.now} #{cur} #{dig.hexdigest}\n" end end :done end end p thrs.map(&:value) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
0 files changed, 0 insertions, 0 deletions