Messages in this thread | | | Date | Fri, 14 May 1999 14:47:31 +0200 | From | Jakub Jelinek <> | Subject | Re: sendfile() |
| |
On Thu, May 13, 1999 at 06:12:34PM -0700, John Myers wrote: > Ingo Molnar wrote: > > one reason we made syscalls so lightweight is to avoid silly > > 'multi-purpose' conglomerate system calls like NT has. sendfile() has > > mainly not been added to avoid system calls being done, but because it's > > strong (and unique) conceptual foundations. Linux syscalls will be even > > more lightweight in the future. (i have a prototype patch that makes them > > cost 0.30 microseconds) Do you see the point, again an apples to oranges > > problem. > > System-call overhead is not the problem with omitting a header argument > to sendfile(). The problem with omitting a header argument to > sendfile() is that the write() causes the header to be sent out as a > short packet. When the application next calls sendfile(), it gets > nailed by Nagle's algorithm.
That is not a problem in Linux. Get used to TCP_CORK:
int optval = 1; off_t off;
setsockopt(sock, SOL_TCP, TCP_CORK, &optval, sizeof(int)); /* Write header */ write (sock, header, sizeof(header); /* Send one file infd1 */ off = 0; sendfile (sock, infd1, &off, size1); /* Send yet another file infd2 */ off = 0; sendfile (sock, infd2, &off, size2); /* Now flush partial frame */ optval = 0; setsockopt(sock, SOL_TCP, TCP_CORK, &optval, sizeof(int));
(of course, this lacks any error handling etc., but you get the picture).
Cheers, Jakub ___________________________________________________________________ Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz Administrator of SunSITE Czech Republic, MFF, Charles University ___________________________________________________________________ UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/ Linux version 2.3.1 on a sparc64 machine (1343.49 BogoMips) ___________________________________________________________________
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |