From: "Patrick J. LoPresti" <lopresti@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Is splice() useful without page stealing?
Date: Thu, 17 Dec 2009 18:47:19 -0800 [thread overview]
Message-ID: <23986fd90912171847w6d46ba2bx9d8763a63fc758c3@mail.gmail.com> (raw)
I just spent a couple of hours tracking down documentation and
discussion on splice(). I apologize in advance if I missed something.
As near as I can tell, SPLICE_F_MOVE (aka. "page stealing") was
removed in 2.6.21
(http://lkml.indiana.edu/hypermail/linux/kernel/0703.1/2592.html) and
never reinstated.
My question is, doesn't this make splice() nearly useless from a
performance perspective?
For example, consider implementing a simple file copy. You might
argue that even without SPLICE_F_MOVE, splice() can be used to avoid
one copy of the data: The standard/portable "read() into a user
buffer and write() from that buffer" is two copies, whereas splice()
to and from a pipe would be one copy.
But that argument is bogus, because modern processors have sizable
caches. If you simply write the portable code to read() into a small
buffer (16K or so) and write() from that buffer, and you use the same
buffer over and over, the data in the buffer should get overwritten in
the L1 cache before it ever gets flushed to the RAM behind it. In
effect, this simple loop would move data into the L1 cache (on read())
and then back into the page cache (on write()), for a net of ONE
round-trip to physical memory.
Similarly for copying data from a socket to a file in an attempt to
implement "recvfile()".
Now, if splice() actually let you do things like flip pages from the
network stack into the page cache with zero copies, then I could see
the point. As it is, I am curious to know:
1) Does anybody have any actual benchmarks showing performance
advantages for splice() over read()/write()? If so, can I obtain the
benchmark code?
2) Are there any plans to reinstate SPLICE_F_MOVE or something equivalent?
Thank you.
- Pat
next reply other threads:[~2009-12-18 2:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 2:47 Patrick J. LoPresti [this message]
2009-12-18 6:34 ` Willy Tarreau
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=23986fd90912171847w6d46ba2bx9d8763a63fc758c3@mail.gmail.com \
--to=lopresti@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®