mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Alex Vorona <voron@amhost.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Re[2]: sendfile to nonblocking socket
Date: Tue, 24 Apr 2007 14:48:27 +0200	[thread overview]
Message-ID: <20070424144827.fdac3bb4.dada1@cosmosbay.com> (raw)
In-Reply-To: <1211570752.20070424143348@amhost.net>

On Tue, 24 Apr 2007 14:33:48 +0400
Alex Vorona <voron@amhost.net> wrote:

> Hello David,
> 
> Tuesday, April 24, 2007, 1:19:49 PM, you wrote:
> 
> >> sendfile function is not just a more efficient version of a read 
> >> followed by a write.  It reads from one fd and write to another at tha
> >> same time. Please try to read 2G, and then write 2G - and how much 
> >> memory you will be need and how much time you will loose while reading
> >> 2G from disk, but not writing them to socket.
> 
> DS> You are correct. What I meant to say was that it's just a
> DS> more efficient version of 'mmap'ing a file and then 'write'ing
> DS> from the 'mmap'. The 'write' to a non-blocking socket can still
> DS> 'block' on disk I/O.
> 
> How can I avoid that blocking? Or maybe another question - how can I
> deliver data from disk to network with minimal copy operations, etc.
> 

I believe the modern way would be to use splice() system call :

loop
 splice(from disk , to pipe) with SPLICE_F_NONBLOCK
 wait_event_from_epoll (pipe ready for reading)
 splice(from pipe, to socket)
 wait_event_from_epoll (socket ready for writing)

But :

1) I am not sure epoll can get an event when page(s) is/are ready in pipe (ie disk delivered the page(s) to cache)
2) I am not sure splice() to socket is actually implemented with 0-copy
3) I am not sure pipe capacity (16 pages) would be enough to get a good readahead.

Eric




  reply	other threads:[~2007-04-24 12:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-23 21:13 voron
2007-04-23 21:59 ` David Miller
2007-04-24  4:42   ` Alex Vorona
2007-04-23 22:52 ` David Schwartz
2007-04-24  4:54   ` Alex Vorona
2007-04-24  9:19     ` David Schwartz
2007-04-24 10:33       ` Re[2]: " Alex Vorona
2007-04-24 12:48         ` Eric Dumazet [this message]
2007-04-24 19:19         ` David Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070424144827.fdac3bb4.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=voron@amhost.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome