From owner-freebsd-net@FreeBSD.ORG Thu Jul 20 03:17:14 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1788E16A4DA for ; Thu, 20 Jul 2006 03:17:14 +0000 (UTC) (envelope-from mi+mx@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 78BE043D55 for ; Thu, 20 Jul 2006 03:17:13 +0000 (GMT) (envelope-from mi+mx@aldan.algebra.com) Received: from corbulon.video-collage.com (static-151-204-231-237.bos.east.verizon.net [151.204.231.237]) by aldan.algebra.com (8.13.6/8.13.6) with ESMTP id k6K3H7QH006990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jul 2006 23:17:11 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) Received: from [172.21.130.86] (mx-broadway [38.98.68.18]) by corbulon.video-collage.com (8.13.6/8.13.6) with ESMTP id k6K3H12o043110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Jul 2006 23:17:02 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) From: Mikhail Teterin Organization: Virtual Estates, Inc. To: "David G. Lawrence" Date: Wed, 19 Jul 2006 23:16:55 -0400 User-Agent: KMail/1.9.1 References: <200607192230.14939.mi+mx@aldan.algebra.com> <20060720025003.GF924@tnn.dglawrence.com> In-Reply-To: <20060720025003.GF924@tnn.dglawrence.com> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-u" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200607192316.56157.mi+mx@aldan.algebra.com> X-Virus-Scanned: ClamAV 0.88/1609/Wed Jul 19 08:13:27 2006 on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.43 Cc: net@freebsd.org Subject: Re: complement to sendfile()? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jul 2006 03:17:14 -0000 ÓÅÒÅÄÁ 19 ÌÉÐÅÎØ 2006 22:50, David G. Lawrence ÎÁÐÉÓÁ×: > š šsendfile() could be extended to allow arbitrary file descriptor types as > the source and destination, but the zero-copy nature of it can only work > in the file to socket direction. This is because network buffers can be > made out of filesystem buffers (file->network direction), but for the > network to file direction network packets arrive non-deterministically. > With the right network hardware it would in theory be possible to have the > TCP code run on the network card and it could DMA the TCP stream directly > into file buffers. If pigs had wings, they could fly. :-) Ok, so zero-copy may not work, but one-copy would still be better, than the usual two-copy. Am I right? With the usual read/write method, data is read from the network card to kernel's buffers, from there to the application buffer, and from there to the filesystem. That's two copies, no? Having mmap-ed the output file, I could read from the socket directly into the mmap-returned "buffer", but writing via. mmap appears to be implemented pessimally in FreeBSD and breaks horrendously if the output file happens to be accessed via NFS. Thanks! -mi