All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Schwartz" <davids@webmaster.com>
To: <linux-kernel@vger.kernel.org>
Subject: RE: sendfile to nonblocking socket
Date: Tue, 24 Apr 2007 02:19:49 -0700	[thread overview]
Message-ID: <MDEHLPKNGKAHNMBLJOLKIEDFDEAC.davids@webmaster.com> (raw)
In-Reply-To: <462D8D92.9050301@amhost.net>


> David Schwartz пишет:
> > You have a misunderstanding about the semantics of 'sendfile'. 
> The 'sendfile' function is just a more efficient version of a 
> read followed by a write. If you did a read followed by a write, 
> it would block as well (in the read).
> >
> > DS

> 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.

You are correct. What I meant to say was that it's just a more efficient version of 'mmap'ing a file and then 'write'ing from the 'mmap'. The 'write' to a non-blocking socket can still 'block' on disk I/O.

> If you know more 
> efficient method to transfer file from disk to network - please advise. 
> Now all I want is really non-blocking sendfile. Currently sendfile is 
> non-blocking on network, but not on disk i/o. And when I have network 
> faster than disk - I get block.

There are many different techniques and which is correct depends on what direction you want to go. POSIX asynchronous I/O is one possibility. Threads plus epoll is another. It really depends upon how much performance you need, how much complexity you can tolerate, and how portable you need to be.

DS



  reply	other threads:[~2007-04-24  9:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-23 21:13 sendfile to nonblocking socket 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 [this message]
2007-04-24 10:33       ` Re[2]: " Alex Vorona
2007-04-24 12:48         ` Eric Dumazet
2007-04-24 19:19         ` David Schwartz
  -- strict thread matches above, loose matches on Subject: below --
2007-04-25 11:41 A.D.F.

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=MDEHLPKNGKAHNMBLJOLKIEDFDEAC.davids@webmaster.com \
    --to=davids@webmaster.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.