sendfile(), splice() and vmsplice() questions
From: Constantine Gavrilov
Date: Wed Jun 22 2022 - 14:44:46 EST
I would like to clarify the behavior of zero-copy TCP sends with
sendfile() and splice() APIs
Assuming the zero copy socket option is set on a TCP socket, and
application is using a shared memory mapping of /dev/dax device or a
file in /dev/shm or /dev/hugepages, will zero copy be used when:
1. sendile() sends multiple page aligned fragments (4k aligned start
and 4k aligned size)?
2. senifile() sends multiple page aligned fragments(4k aligned start)
but the size is not 4k aligned?
3. sendfile() sends multiple fragments but the first fragment is not
page aligned?
4. If a pipe was populated with vmsplice() without SPLICE_F_GIFT, will
splice() from the pipe to a socket will do zero copy?
5. If a pipe is populated with small buffers (headers) and full pages,
will splice from a pipe to socket will do zero copy at least on full
pages if the transfer spans both? What if the splice() falls within a
partial page (non-zero offset or size of a fragment less than the page
size)?
6. can vmsplice() populate the pipe with zero copy at least on full
pages, if it is given an iovec of headers and full pages?
And regarding completion semantics:
1. Is it true that splice() and sendfile() on socket will return when
the data is "written" to the socket buffer? If true, is there an
indication in the error queue about "wire" completion (as with
sendmsg() with MSG_ZEROCOPY)?
2. Can I use send() before and after sendfile() and know that the
order of the packets in TCP stream is preserved?
I assume that vmsplice() still does not work on sockets. Was there any
work done to provide an equivalent interface on sockets?
Much thanks for your answers.
--
----------------------------------------
Constantine Gavrilov
Storage Architect
Master Inventor
Tel-Aviv IBM Storage Lab
1 Azrieli Center, Tel-Aviv
----------------------------------------