[web-devel] Content-Length on sendFile

Max Cantor mxcantor at gmail.com
Wed Jun 15 09:13:17 CEST 2011


wouldn't the overhead of reading from the drive dominate the overhead of copying the contents from userspace to kernel space?

max

On Jun 15, 2011, at 3:10 PM, Kazu Yamamoto (山本和彦) wrote:

> 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
> 
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel




More information about the web-devel mailing list