You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Increasing read chunk size could improve performance for large responses #135
Benchmarking using @dalf's pyhttp-benchmark tool led us to see that increasing this number to 64kB could lead 2-3x execution time improvement for large responses (typically > 256kB).
My rationale would be that reading N bytes in one go via a syscall is faster than reading n = N/k bytes k times — mostly because the kernel is way faster than Python.
Running the 1MB-response benchmark for various READ_NUM_BYTES values, and a matplotlib script later, here's a handy little plot to support this assessment that 64kB is probably a good value…
Looks like the median execution time gets exponentially smaller as we increase the chunk size. Once we hit 32kB the marginal improvement starts hitting its limits. 64kB gets us "below 1s in wall time for a 1MB response" and that sounds very satisfying. :-)
Activity
florimondmanca commentedon Aug 5, 2020
Running the 1MB-response benchmark for various
READ_NUM_BYTESvalues, and a matplotlib script later, here's a handy little plot to support this assessment that 64kB is probably a good value…Looks like the median execution time gets exponentially smaller as we increase the chunk size. Once we hit 32kB the marginal improvement starts hitting its limits. 64kB gets us "below 1s in wall time for a 1MB response" and that sounds very satisfying. :-)
dalf commentedon Aug 5, 2020
An additional graph (made using this tool):

httpcore_True_*: http2=Truehttpcore_False_*: http2=False