From owner-freebsd-net@FreeBSD.ORG Sat Mar 20 17:53:41 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 281F71065700 for ; Sat, 20 Mar 2010 17:53:41 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by mx1.freebsd.org (Postfix) with ESMTP id E97658FC0A for ; Sat, 20 Mar 2010 17:53:40 +0000 (UTC) Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 4B209E805D for ; Sat, 20 Mar 2010 13:53:40 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Sat, 20 Mar 2010 13:53:40 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=V/JYrhjG+eDPAjf4pcTCu7SSR2o=; b=VGwg32cUuUr3J0sXQvjaaUcbKoWVWWRHKtAcevwp2lQrmXu7ehAn0JxgAabmLh53sbAPHmh5wmLBmI2qsWpn/kkGQ9MJwnIkxxKs/AaSj75ozaAtA1qUiBuiYbA31XFv5k9rApwVQ84AGEgU1B/crgeXf6PN+OAK0rSSVVPqx8Y= X-Sasl-enc: BWUSSfZarqCUteGB5CGuRhYygC86UWM1M67IjHSs4bEQ 1269107620 Received: from anglepoise.lon.incunabulum.net (cpc2-dals7-0-0-cust253.hari.cable.virginmedia.com [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id DE7AB10B97 for ; Sat, 20 Mar 2010 13:53:39 -0400 (EDT) Message-ID: <4BA50BA1.5060401@incunabulum.net> Date: Sat, 20 Mar 2010 17:53:37 +0000 From: Bruce Simpson User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.8) Gecko/20100302 Thunderbird/3.0.3 MIME-Version: 1.0 To: freebsd-net@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: why zero-copy sockets(9) are not popular? 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: Sat, 20 Mar 2010 17:53:41 -0000 On 03/20/10 10:06, Alexander Bubnov wrote: > Hello, all! > Anybody knows why zero copy is not popular although this technique allows > to increase performance of servers? It is very hard to find any examples of > zero-copy for FreeBSD. > Transmit is easy. Receive is hard. The whole concept of zero-copy revolves around being able to use page-flipping to map buffers in user and kernel space, to amortize the cost of copies across that system boundary. The compromise usually taken is to use the sendfile() API, or rely on TCP Segmentation Offload (TSO), much like Microsoft's Chimney stack does in Windows 7. Unfortunately, sendfile() only covers transmit. TSO only offloads up to the point where sockets hit the card; TSO can offload TCP stream reassembly, but you still have to copy from the kernel buffers into userland. True zero-copy sockets generally require scatter/gather DMA engine support, and TCP/IP header splitting, to do zero-copy recieve. S/G PCI DMA cores are often custom designed, and you tend not to find them in off-the-shelf VHDL libraries. That IP (as in intellectual property) still has cost. Historically the only cards in FreeBSD which supported this, were the Tigon-II, which got bought by Broadcom (bge is the Tigon-III). Modified firmware was required to do this.