about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <bofh@yhbt.net>2022-12-22 09:02:10 +0000
committerEric Wong <e@yhbt.net>2022-12-22 09:02:51 +0000
commit17969a9a67ae8db7dbc227a8afbb220b94d08e7f (patch)
tree99ecc30f1144a7182507d4210de9cbe7a2031abd
parente263cc5a5771dfdeb6811f812d8b054e5404621f (diff)
downloadyahns-17969a9a67ae8db7dbc227a8afbb220b94d08e7f.tar.gz
This is the size used by Ruby internally for IO.copy_stream.
8192 seems too small nowadays with the higher cost of syscalls.
-rw-r--r--lib/yahns/http_client.rb2
-rw-r--r--lib/yahns/proxy_http_response.rb4
-rw-r--r--lib/yahns/req_res.rb6
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index b6b6035..826eb8d 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -315,7 +315,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
   end
 
   def do_pread(io, count, offset)
-    count = 0x4000 if count > 0x4000
+    count = 16384 if count > 16384
     buf = Thread.current[:yahns_sfbuf] ||= ''.dup
     if io.respond_to?(:pread)
       io.pread(count, offset, buf)
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index d4a3dda..db9c4b7 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -147,7 +147,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   def read_len(len)
-    max = 0x2000
+    max = 16384
     max = len if len && len < max
     max
   end
@@ -206,7 +206,7 @@ module Yahns::HttpResponse # :nodoc:
     wbuf = req_res.resbuf
 
     until kcar.trailers(tlr, chunk)
-      case rv = req_res.kgio_tryread(0x2000, rbuf)
+      case rv = req_res.kgio_tryread(16384, rbuf)
       when String
         chunk << rv
       when :wait_readable
diff --git a/lib/yahns/req_res.rb b/lib/yahns/req_res.rb
index 4ad8e5c..283fea8 100644
--- a/lib/yahns/req_res.rb
+++ b/lib/yahns/req_res.rb
@@ -29,7 +29,7 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
       case resbuf = @resbuf # where are we at the response?
       when nil # common case, catch the response header in a single read
 
-        case rv = kgio_tryread(0x2000, buf)
+        case rv = kgio_tryread(16384, buf)
         when String
           if res = req.headers(@hdr = [], rv)
             return c.proxy_response_start(res, rv, req, self)
@@ -48,7 +48,7 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
 
       when String # continue reading trickled response headers from upstream
 
-        case rv = kgio_tryread(0x2000, buf)
+        case rv = kgio_tryread(16384, buf)
         when String then res = req.headers(@hdr, resbuf << rv) and break
         when :wait_readable then return rv
         when nil
@@ -114,7 +114,7 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
     # we should not be waiting on a slow network resource when reading
     # input.  However, some weird configs may disable this on LANs
     # and we may wait indefinitely on input.read here...
-    while input.read(0x2000, rbuf)
+    while input.read(16384, rbuf)
       if chunked
         buf[0] = "#{rbuf.size.to_s(16)}\r\n".freeze
         buf[1] = rbuf