News for hackers. Stuff that matters.
Re:Serving Netflix Video at 400Gb/s on FreeBSD [pdf] by drewg123 on Monday September 20, 2021 @12:20PM (#28595497)
There is no context switch, like most system calls, sendfile runs in the thread context of the thread making the syscall.

FreeBSD has "async sendfile", which means that it does not block waiting for the data to be read from disk. Rather, the pages that have been allocated to hold the data are staged in the socket buffer and attached to mbufs marked "not ready". When the data arrives, the disk interrupt thread makes a callback which marks the mbufs "ready", and pokes the TCP stack to tell them they are ready to send.

This avoids the need to have many threads parked, waiting on disk io to complete.

There are no comments on this comment yet.