From owner-freebsd-arch@FreeBSD.ORG Mon Apr 28 00:19:31 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2822E106566B for ; Mon, 28 Apr 2008 00:19:31 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from outbound0.mx.meer.net (outbound0.mx.meer.net [209.157.153.23]) by mx1.freebsd.org (Postfix) with ESMTP id 055938FC0C for ; Mon, 28 Apr 2008 00:19:30 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from mail.meer.net (mail.meer.net [209.157.152.14]) by outbound0.mx.meer.net (8.12.10/8.12.6) with ESMTP id m3S092ht042679; Sun, 27 Apr 2008 17:09:03 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from mail2.meer.net (mail2.meer.net [64.13.141.16]) by mail.meer.net (8.13.3/8.13.3/meer) with ESMTP id m3S08MSi029667; Sun, 27 Apr 2008 17:08:24 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from minion.local.neville-neil.com (71-217-30-178.tukw.qwest.net [71.217.30.178]) (authenticated bits=0) by mail2.meer.net (8.14.1/8.14.1) with ESMTP id m3S08DkJ073003; Sun, 27 Apr 2008 17:08:15 -0700 (PDT) (envelope-from gnn@neville-neil.com) Date: Sun, 27 Apr 2008 17:07:56 -0700 Message-ID: From: gnn@freebsd.org To: Andre Oppermann In-Reply-To: <4811E384.5020604@freebsd.org> References: <4811E384.5020604@freebsd.org> User-Agent: Wanderlust/2.15.5 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.1.50 (i386-apple-darwin8.11.1) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: arch@freebsd.org Subject: Re: Accounting for mbufs and clusters assigned to a socket buffer X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Apr 2008 00:19:31 -0000 At Fri, 25 Apr 2008 15:58:28 +0200, andre wrote: > > gnn@freebsd.org wrote: > > Howdy, > > > > The following patch updates the kernel (CURRENT as of 23 April or so) > > and netstat(1) to show not only the bytes in the receive and send > > queues but also the mbuf and cluster usage per socket buffer. I'd be > > interested in people's comments on this. I'd like to extend such > > counting to show more information, in particular how much of a cluster > > or mbuf is actually in use. > > The intent of tracking that information is good. However there are some > problems with your approach: M_EXT does not mean the mbuf has a 2k cluster > attached. It could by any external storage. That is a 2k (classic) cluster, > a 4k (page size) cluster, a 9k cluster, a VM page (sendfile), and so on. Yup, this is a first cut. > The field sb_mbcnt already gives you the aggregated gross storage > space in use for the socket. And sb_cc tells how much actual > payload it contains. Right but it does not tell us the mix of clusters vs. mbufs, which is something useful for tuning. For instance, if you find you have a high use of clsuters but only because mbufs are 256 bytes, that is your application's normal traffic is on average 300 byte packets, that might lead you to push mbufs to 512 bytes. > Just printing the already available sb_mbcnt in netstat is probably > sufficient to get a good real memory usage picture. sb_mbcnt is > already exported in xsb and doesn't require a KPI change. > Well, it is perhaps interesting as it shows space wastage, but I don't think it's as complete a solution for showing the mix of cluster and mbuf usage. I do think I should come up with a way to print it though, which probably requires a new flag to netstat so that the normal usage is not polluted. Best, George