splice( ) not giving performance gains over sendto( )
I am doing some experimentation work on the splice ( ) system call. My hardware does not support Scatter-Gather DMA. I have 2 server applications for transmiiting data over the network using TCP. In both the applications a socket is opened, binded to a port and after listening on the port, accepts a connection from the client side. I connect to the server side from another linux box on the same network. Both open a /dev/zero file of the required size for sending over the network. Now, the difference between the two lies in the mechanism used for transmitting the file over the network.
1). One application uses a combination of read( )/sendto( ) system calls i.e.
read( ) -> to read contents of the file and
sendto( )-> to send the read contents to the connected socket (client side).
2). The other application uses the 'splice mechanism' for sending the data. i.e.
splice( )-> the data from the file into a pipe and then another
splice( )-> to send the contents fo the pipe to the connected socket (client side)
Though i am not noticing any data loss in transmitting the file over the network, the times taken for both the applications are around the same. i.e. I am not observing any throughput gains when using splice( ) over read( )/sendto( ).
I am wondering if splice( ) gives performance gains only when the hardware supports Scatter-Gather DMA or there is some other problem. I would be grateful to anybody who can shed some light on the above observations.