3 ms·
I wonder if Linux has considered the technique that FreeBSD uses for async sendfile? The FreeBSD sendfile() syscall is async (mostly; there is a potential to b
by drewg123 8y ago
I wonder if Linux has considered the technique that FreeBSD uses for async sendfile?
The FreeBSD sendfile() syscall is async (mostly; there is a potential to block reading metadata in VOP_BMAP). It launches a request to read disk blocks into pages, and attaches the pages to the socket buffer via mbufs, but marks them M_NOTREADY so that the protocol layer cannot send them. When the disk I/O completes, the mbufs are marked ready in the context of the disk interrupt thread, and then the proto output routine (eg, tcp_output()) is called.
This is more-or-less fire and forget for nginx. (yes, it does check the status via kqueue, but it does not block)
This was a huge performance win for us at Netflix, and the not-ready concept is the basis for our kernel-tls layer (mbufs are left not-ready, and encrypted after the disk read, and then the crypto thread calls the proto output).