LWN: Comments on "Two new system calls: splice() and sync_file_range()" http://lwn.net/Articles/178199/ This is a special feed containing comments posted to the individual LWN article titled "Two new system calls: splice() and sync_file_range()". hourly 2 heavy-duty philosophy http://lwn.net/Articles/179208/rss 2006-04-10T01:03:58+00:00 xoddam <font class="QuotedText">&gt; splice() must truly be a great philosopher! </font><br> <br> This is an in-joke, from the text adventure game version of Douglas <br> Adams' Hitch-Hiker's Guide to the Galaxy: <br> <br> <font class="QuotedText">&gt;open door </font><br> The door explains, in a haughty tone, that the room is occupied <br> by a super-intelligent robot and that lesser beings (by which <br> it means you) are not to be admitted. "Show me some tiny example <br> of your intelligence," it says, "and maybe, just maybe, I might <br> reconsider." <br> <br> <font class="QuotedText">&gt;get tea </font><br> no tea: Dropped. <br> <br> <font class="QuotedText">&gt;get no tea </font><br> no tea: Taken. <br> <br> <font class="QuotedText">&gt;inventory </font><br> You have: <br> no tea <br> tea <br> a small key <br> a flowerpot <br> a thing your aunt gave you which you don't know what it is <br> a babel fish (in your ear) <br> <br> <font class="QuotedText">&gt;open door </font><br> The door is almost speechless with admiration. "Wow. Simultaneous <br> tea and no tea. My apologies. You are clearly a heavy-duty <br> philosopher." It opens respectfully. <br> It is zero-copy http://lwn.net/Articles/179135/rss 2006-04-08T18:26:26+00:00 axboe Copy is in quotes, because it's not the CPU doing the copy. Which is what is interesting, and why zero-copy just means zero CPU copies. That is where you pay the cost, at least in CPU cycles and potentially also in cache. So zero-copy definitely isn't just a play on words. It may sometimes be used in silly marketing ways, but if you are CPU bound it makes all the difference in the world that the CPU doesn't have to touch the data.<br> <p> And yes, the normal copy is indeed two copies, to and from kernel/user space.<br> <p> You can continue talking if you want, but don't expect a response from me.<br> It is zero-copy http://lwn.net/Articles/179131/rss 2006-04-08T17:31:39+00:00 giraffedata <blockquote> So a splice based copy will be zero memory copies, and two DMA "copies" </blockquote> <p> I presume "copies" is in quotes because you agree with me that the DMA operations are not copies in the sense we're talking about. (If they were, a "zero-copy" file read wouldn't be zero-copy, and moving data from kernel file data cache to user space would be two copies (kernel memory to register, register to user memory)). <p> However, the combination of the two DMAs constitutes one disk copy. A disk copy is an instance of replicating data from one place on a disk to another, just as a memory copy is an instance of replicating data from one place in memory to another. And it's worth talking about because it takes time. If you could truly do a zero-copy copy, that would be remarkable. As it stands, "zero-copy copy" is just a trick of words in which you change the definition of copy in the middle of the sentence. <blockquote> A normal copy contains the same number of DMA operations, but includes a memory copy. </blockquote> <p>Actually, the most normal file copy includes two memory copies -- from kernel file data cache of the source file to user space buffer, and from that buffer to the other file's kernel file data cache. With mmap, you can get it down to one, and with direct I/O you can get to zero. It is zero-copy http://lwn.net/Articles/179112/rss 2006-04-08T11:14:34+00:00 axboe A splice based copy does no copies. The source data is DMA'ed from hardware to the source file page(s), then those pages are moved to the destination and dirted to so will eventually go out to disk again with another DMA operations.<br> <p> A normal copy will DMA those pages in, allocate pages in the target file address space, copy that data over, and then it'll be DMA'ed to disk again. So two DMA operations, and one full copy of all the data.<br> <p> So a splice based copy will be zero memory copies, and two DMA "copies" (the dma operation above may be a series of dma transactions, depending on how large the file is). A normal copy contains the same number of DMA operations, but includes a memory copy.<br> It is zero-copy http://lwn.net/Articles/179092/rss 2006-04-07T22:46:27+00:00 giraffedata It sounds funny only because you're using "copy" two different ways in the same sentence. When we talk about copying a file, we're talking about copying from disk to disk. When we say zero-copy, we're talking about copying data from memory to memory. <p>A splice-based file copy does one disk-disk copy, and no memory-memory copy, as contrasted with the traditional file copy that does one disk-disk copy plus two memory-memory copies. <P>Since the naive observer wouldn't even expect there to be memory-memory copies involved in copying files, "zero copy file copy" shouldn't sound odd at all. It is zero-copy http://lwn.net/Articles/178737/rss 2006-04-06T07:16:33+00:00 axboe <font class="QuotedText">&gt; Wow! Copying without copying! splice() must truly be a great philosopher!</font><br> <p> Yeah it sounds crazy, but it's really true :-). You bring in the pages from the source file, then migrate them to the address space of the target file. Bingo, zero copy copies!<br> It is zero-copy http://lwn.net/Articles/178729/rss 2006-04-06T06:42:27+00:00 xoddam <font class="QuotedText">&gt; It is zero-copy </font><br> <br> Sorry -- I misremembered Linus' original pipe-buffer <br> discussion. It has been a while: <br> <br> <a href="http://lwn.net/Articles/118760/">http://lwn.net/Articles/118760/</a> <br> <br> <font class="QuotedText">&gt; Splice can even do zero-copy file copies </font><br> <br> Wow! Copying without copying! splice() must truly be a great philosopher! <br> It is zero-copy http://lwn.net/Articles/178725/rss 2006-04-06T05:59:33+00:00 axboe It is zero-copy, why do you think the pipe pages are copied before being transmitted? Splice can even do zero-copy file copies, by moving pages from one file to another.<br> And what becomes of zero-copy? http://lwn.net/Articles/178682/rss 2006-04-06T01:13:53+00:00 xoddam <font class="QuotedText">&gt; The splice git branch has support for fd -&gt; fd splicing now </font><br> <font class="QuotedText">&gt; (by using a virtual pipe), so sys_sendfile can basically </font><br> <font class="QuotedText">&gt; just use that. </font><br> <br> But the internal pipe buffer uses dedicated pages, so there is <br> a minimum of one copy involved. Doesn't sendfile() do zero-copy <br> from a file's pages to a socket, if the socket's driver supports <br> it? <br> <br> Also why isn't splice() just called cat()? <br> Two new system calls: splice() and sync_file_range() http://lwn.net/Articles/178376/rss 2006-04-04T15:02:55+00:00 axboe sys_sendfile() can never go, as it's a part of the user space ABI. However, the internal implementation can be replaced with a call to splice() instead. The splice git branch has support for fd -&gt; fd splicing now (by using a virtual pipe), so sys_sendfile can basically just use that.<br> Two new system calls: splice() and sync_file_range() http://lwn.net/Articles/178365/rss 2006-04-04T14:13:05+00:00 zlynx I gathered from LKML that sendfile is going to become a call to splice. But sendfile will probably stay in the kernel for many versions to come for legacy support. Linus does try to keep ABI compatibility for user-space.<br> Two new system calls: splice() and sync_file_range() http://lwn.net/Articles/178340/rss 2006-04-04T11:26:44+00:00 andersg Is splice going to deprecate sendfile(2)?<br> Two new system calls: splice() and sync_file_range() http://lwn.net/Articles/178293/rss 2006-04-03T23:44:39+00:00 TwoTimeGrime Nevermind. I saw in <a href="http://lwn.net/Articles/164887/">http://lwn.net/Articles/164887/</a> that it described how splice works at the bottom of the article.<br> Two new system calls: splice() and sync_file_range() http://lwn.net/Articles/178291/rss 2006-04-03T23:40:26+00:00 TwoTimeGrime Could someone please explain what the effect of splice() is supposed to be? Is it just a faster way for the kernel to move data from one place to another? Is this something that programs would use or would it be something that other parts of the kernel use? I see that it has fdin and fdout as arguments. Does that mean that it uses file descriptors and can be used for copying files? I don't know anything about kernel development so I'm trying to put this feature into context.<br> <p> Thanks.<br>