Async IO i mean, writer thread does loop and sends as much as possible
chunks from the files, same way as driver thread reads multiple chunks
of requests from multiple clients. sendfile blocks, so you will need 10
threads for 10 clients at the same time, in case of writer thread, it
can alone transfer 10 files to 10 clients. May be it will be slower in
each single case comparing to sendfile but overall it does it fast enough.

Vlad,
Sorry, but your assertion is not correct.  sendfile() is not required
to block - as far as I am aware it works on non-blocking sockets
without a problem.  The key advantages of using sendfile is that it is
implemented zero-copy and allows the OS to do large-block read-ahead
on the files.  If serving 100 clients 650MB files, using non-blocking
IO read+write needs to allocate local buffers.  If buffers are small
(e.g. 100KB) then the disk has to seek like crazy from file to file,
and that will kill performance.  If the buffers are large (e.g. 16MB)
then the disk seek will be fine but I will need to burn 1.6GB of RAM
for the buffers in the NS process...  How does NS decide what this
buffer size is?  Can you point me at the code that performs this
operation?  How challenging would it be to add optional sendfile
support here?

Reply via email to