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
The io.Copy implementation is synchronous. It reads and writes in a for loop on a single thread. When read and write costs are high (i.e. using net.Conn) it cal halve the performance.
We could easily optimize that by prefetching data while writing.
Now
R R R
W W W
Desired
RRR
WWW
Implementation idea:
Reader uses two buffers 128K each
If buffer capacity goes below 32kiB the buffers are switched
Reader sends buffer subslices to writer over a channel, channel capacity is 1
Writer writes what it gets over the channel as in io.Copy
Note use subslice with capacity [start:len:cap] syntax.
The text was updated successfully, but these errors were encountered:
The io.Copy implementation is synchronous. It reads and writes in a for loop on a single thread. When read and write costs are high (i.e. using net.Conn) it cal halve the performance.
We could easily optimize that by prefetching data while writing.
Now
Desired
Implementation idea:
Note use subslice with capacity
[start:len:cap]
syntax.The text was updated successfully, but these errors were encountered: