normal 7db24a6269 net/http: use writev for HTTP chunked request bodies
This reduces both user and system CPU time for large
uploads with dynamically-generated request bodies.

              user     system      total        real
before:   0.393334   1.580000   1.973334 (  1.971066)
after:    0.223334   0.976666   1.200000 (  1.198514)

------
require 'socket'
require 'net/http'
require 'benchmark'
nr = 1024 * 1024 * 1024
s = TCPServer.new('127.0.0.1', 0)
addr = s.addr
at_exit { Process.waitall }
fork do
  c = s.accept
  # not exactly accurate but fast
  IO.copy_stream(c, '/dev/null', nr + 500000)
  begin
    buf = c.readpartial(16384)
    tmp = ''
    until buf.end_with?(-"0\r\n\r\n")
      buf << c.readpartial(16384, tmp)
    end
  rescue EOFError
  end
  c.write "HTTP/1.1 201 Created\r\nConnection:close\r\n\r\n"
  c.close
end
r, w = IO.pipe
fork do
  r.close
  IO.copy_stream('/dev/zero', w, nr)
  w.close
end
w.close
Net::HTTP.start(addr[3], addr[1]) do |http|
  put = Net::HTTP::Put.new('/dev0/foo')
  put['Content-Type'] = 'application/content-type'
  put['Transfer-Encoding'] = 'chunked'
  put.body_stream = r
  puts(Benchmark.measure { http.request(put) })
end
------

* lib/net/http/generic_request.rb (write): use multi-arg write
* lib/net/protocol.rb (write): support multi-arg
  (write0): ditto
  [ruby-core:84845] [Feature #14339]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 02:44:53 +00:00
..
2017-12-30 12:10:43 +00:00
2017-10-22 11:27:06 +00:00
2017-12-31 00:06:34 +00:00
2017-10-08 07:00:01 +00:00
2017-12-25 05:54:27 +00:00
2017-10-08 07:00:01 +00:00
2017-12-14 06:30:22 +00:00
2017-12-24 08:38:43 +00:00
2017-09-12 08:38:06 +00:00
2017-12-22 08:00:10 +00:00
2017-12-22 08:00:10 +00:00
2017-09-02 02:05:34 +00:00
2017-10-21 13:34:19 +00:00
2017-12-25 07:55:25 +00:00
2018-01-11 19:36:30 +00:00
2017-10-08 07:00:01 +00:00
2017-10-08 07:00:01 +00:00
2017-12-23 23:33:09 +00:00
2017-12-22 23:08:05 +00:00
2018-01-07 17:49:46 +00:00
2017-11-22 21:13:51 +00:00
2017-10-08 07:00:01 +00:00
2017-10-08 07:00:01 +00:00