Open cpuguy83 opened 3 years ago
Updated this, added some new test cases and improved the implementation slightly:
1<<62
... which is a lot... but is not expected since we want to copy until EOF (splice copies 0 bytes), so the internal copy takes a special value, -1
, to mean copy to EOF. This is important because we have special handling for when the reader passed in to ReadFrom
is an *io.LimitedReader
and this was originally mixing "amount to copy" with "amount remaining to copy".I'm going to do some more testing on this as well.
FYI, ended up making a new repo to play around with this a bit more, benchmarks, etc: https://github.com/cpuguy83/pipes Somewhat suprisingly I'm seeing an approx 2x speedup using splice.
I've made some changes to the implementation that make it a bit cleaner which I'll move here as well.
Somewhat suprisingly I'm seeing an approx 2x speedup using splice.
Silly question; the benchmark in the readme doesn't show a delta; is that because some option wasn't set?
(Performance improvement sounds great though!)
Hmm I'm not sure. I hadn't used benchstat before... benchcmp shows the delta.
@cpuguy83 @kzys @dmcgowan what's the status on this one? Do we want to have this merged and included in a release?
I went looking what changes are in main
that are not yet released (following https://github.com/containerd/fifo/pull/32#issuecomment-1023065555), so was looking if we wanted to include this PR as well if we would be doing a new release.
Sorry. I have missed the ping. Let me take a look next week.
On Linux, we can use
splice
to optimize copies to happen in kernel when copying to other files. Since this is already a pipe, this should always work when copying to/from another file.