-
Notifications
You must be signed in to change notification settings - Fork 18k
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: make (*TCPConn).ReadFrom(r) use sendfile syscall when r is io.SectionReader of *os.File #6374
Labels
Milestone
Comments
Markus sent https://golang.org/cl/69870051/ |
Comment 7 by markus@distinctive.co: So would the preference be to have a new type of reader, like FileSectionReader for example, that would specifically address this network use-case rather than exposing more of the SectionReader's internal state? If there is question of the value of this feature, our specific case streams entries to a file and then periodically ships file chunks to a remote server in a single process, we have seen a noticeable increase in performance by deferring to the OS/sendfile under strained workloads. |
The goal is to have a consistent and simple API above all else. Performance is nice, but not if it means adding new confusing types for rare cases. That means all readers of the io package docs have the cognitive burden of seeing that new type and its docs and understanding why they should or shouldn't use it. If a new type is only for performance, and the performance is actually worth it in many cases, and it's not something people can do on their own easily without forking lots of code, then it's possible we could support it in more gross/magic ways. Exposing io.LimitedReader (it used to be hidden) was already a bit of a compromise. But now that LimitReader + sendfile works, it's unclear we need to make all the reader wrapper types work with sendfile--- you can make a LimitReader now and use it with ReadFrom. If you made the SectionReader then you already have the *os.File. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by valyala:
The text was updated successfully, but these errors were encountered: