[web-devel] Content-Length on sendFile

Kazu Yamamoto ( 山本和彦 ) kazu at iij.ad.jp
Wed Jun 15 09:10:43 CEST 2011


Hello,

>> The server saves all embedded files to the file sytem on boot time and
>> obtains file descriptors for them. And it *unlink* files so that
>> nobody but the server can touch. Then the server can send the file
>> with sendfile. (sendfile API should take FD not FilePath)
> 
> Is this to get the increased performance of the sendfile system call?
> I very much doubt it would work out faster. With embedded files, the
> entire static file is stored as a contiguous chunk of memory. It's
> worth an analysis before recommending this approach, of coruse.

If we use send() to send a chunk of memory, the data is copied
from the user space to the kernel space.

If we use sendfile(), the file is mapped to the kernel space and no
copy happens and the pages are probably cached. But this approach
cosumes double memory.

But I'm not sure this guess is true.

If we can map the user space to the kernel space and can feed the
kernel space to a socket, it's fastest. But I don't know such system
calls.

--Kazu



More information about the web-devel mailing list