6 ms·
>Memory bandwidth is saved by employing the splice() system call to feed data directly from the hard disk into the HTTP connection, without passing the kernel/u
by Dowwie 5y ago
>Memory bandwidth is saved by employing the splice() system call to feed data directly from the hard disk into the HTTP connection, without passing the kernel/userspace boundary (“zero-copy”).
What are the memory savings of this splicing approach as compared to streaming [through userspace]?
- db48x 5y ago67% savings. If an application reads a 1MB file the normal way, the kernel creates 1MB of buffers in the file system cache to hold the data. Then it copies the data to another 1MB of buffers which are owned by the application. If the application then writes the data out to a network socket, the kernel has to allocate another 1MB buffer to hold the data while it is being sent. If the application were processing the data in some way, then it would be worth it. Otherwise it is better to skip all of that work.
- max_k 5y agoWhat does "streaming buffers" mean? splice() avoids copying data from kernel to userspace and back; it stays in the kernel, and often isn't even copied at all, only page references are passed around.