3 ms·
In 2.6.31, support was added to > Allow splice(2) to work when both the input and the output is a pipe. http://git.kernel.org/?p=linux/kernel/git/torvalds/lin
by fragmede 16y ago
In 2.6.31, support was added to
> Allow splice(2) to work when both the input and the output is a pipe.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7c77f0b3f9208c339a4b40737bb2cb0f0319bb8d http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6...
- alexgartrell 16y agoThis goes half way toward solving the problem. What most people want is a pure socket->socket. As evidenced by haproxy, you must still use a pipe intermediary, requiring multiple data copies (on the plus side, it's still fast). ret = splice(fd, NULL, b->pipe->prod, NULL, max, SPLICE_F_MOVE|SPLICE_F_NONBLOCK); edited to add (because I couldn't reply): It almost certainly is faster than read/write, because it's straight memcpy's (which are pretty fast on modern hardware), instead of memcpy's, context switching, special read()/write() logic, and other stuff.
- FooBarWidget 16y agoIs that still faster than userspace forwarding with read() and write()?
- caf 16y agoThe pipe intermediary doesn't necessarily add a copy. You SPLICE_F_MOVE the data from the first fd to the pipe, then SPLICE_F_MOVE it from the pipe to the second fd. If either or both of those can be done zero-copy, they will be. The pipe intermediary is just a way of holding onto the reference-counted pages.