-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: add tcp WriteTo func to enable splice socket data to file #48530
Comments
What are the specific API changes you are proposing? |
This proposal has been added to the active column of the proposals project |
It looks like there are no direct API changes other than TCPConn implementing io.WriterTo by adding a WriteTo method. If splice isn't applicable to this specific TCPConn, So the only possible change is when splice is an option but not the best option. Does that case exist? |
If we do find such a case, TCPConn.WriteTo can always not use splice then. |
Based on the discussion above, this proposal seems like a likely accept. |
Currently, I just find two cases:
Two cases has been handled in https://go-review.googlesource.com/c/go/+/319593 |
No change in consensus, so accepted. 🎉 |
Optimized http get code based on enable splice socket data to file: https://github.com/jim3ma/go/tree/dev.http.writeto.1.16-2021-11-28 Typical testing result(download 1 Gigabytes using http.Get):
testing code:
|
Is there anything missing in the CL? I am also interested in this feature since this will speed up writes from TCP sockets to files. |
Nothing, I think that CL is ready. |
hi @jim3ma! any chance you can rebase your CL? Maybe we can get the ball rolling again? 🤞 |
When transfer data from tcp socket to file directly, splice will help us with low time cost in linux. Currently,
os.File
just useswrite
to transfer data from tcp socket.To do this in linux, there are some changes:
LimitWriter
to detect writing limit in internal package, discussed in this issues.spliceW
function to splice data from tcp socket to file.WriteTo
function fornet.TCPConn
.We get 10% at least cpu time reduce, zero memory copy from kernel to user space.
Implement PR: #46149, go review
The text was updated successfully, but these errors were encountered: