Re:Using Flat Files So Elections Don’t Break Your Server
by dedward on Tuesday December 21, 2010 @09:36AM
(#2027876)
sendfile() still requires CPU time - it just passes the job of sending the data over the socket to the kernel to finish up. The previous method would have been a select() loop or similar that ensured the data was sent out to the kernel, involving a bunch of system calls and context swtiches.
sendfile lets you hand the job off 100% to the kernel and have your thread move on.
[ Parent
| on HN ]
Re:Using Flat Files So Elections Don’t Break Your Server
by sambeau on Tuesday December 21, 2010 @12:08PM
(#2028419)
I was under the (possibly mistaken) impression that Direct Memory Access (DMA) hardware could move data straight from the Disk Cache to the Network card without touching the CPU Caches at all.
Re:Using Flat Files So Elections Don’t Break Your Server
by dedward on Wednesday December 22, 2010 @10:00PM
(#2033360)
True - DMA can do that - but then you'd have to have something managing the network stack - the kernel manages tcp/ip.
From the man page:
"sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space."