From owner-freebsd-net Mon Jul 1 4:35:44 2002 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 B5A7637B400 for ; Mon, 1 Jul 2002 04:35:41 -0700 (PDT) Received: from mailtoaster1.pipeline.ch (mailtoaster1.pipeline.ch [62.48.0.70]) by mx1.FreeBSD.org (Postfix) with SMTP id 9EE9043E1A for ; Mon, 1 Jul 2002 04:35:40 -0700 (PDT) (envelope-from oppermann@pipeline.ch) Received: (qmail 33215 invoked from network); 1 Jul 2002 11:34:43 -0000 Received: from unknown (HELO pipeline.ch) ([62.48.0.53]) (envelope-sender ) by mailtoaster1.pipeline.ch (qmail-ldap-1.03) with SMTP for ; 1 Jul 2002 11:34:43 -0000 Message-ID: <3D203E3B.F8F91B9B@pipeline.ch> Date: Mon, 01 Jul 2002 13:34:19 +0200 From: Andre Oppermann X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Luigi Rizzo Cc: net@freebsd.org Subject: Re: Should we keep a cache of mbuf+cluster ready for use ? References: <20020629145303.A75543@iguana.icir.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Luigi Rizzo wrote: > > Hi, > during some experiments i was doing recently, i noticed that there > is a significant improvement in the forwarding speed (especially > at very high speeds) if we keep a small pool of mbuf+cluster > ready for use. This is because most network drivers do something > like this > > MGETHDR(m_new, M_DONTWAIT, MT_DATA); > if (m_new == NULL) > return(ENOBUFS); > > MCLGET(m_new, M_DONTWAIT); > if (!(m_new->m_flags & M_EXT)) { > m_freem(m_new); > return(ENOBUFS); > } > > when replenishing the receive buffers, and both macros are quite > long even if there are available blocks in the free lists. We can > store buffers of this form when/if they are released with some code > like this: > > if (my_pool_count < my_pool_max && m->m_next == NULL && > (m->m_flags & M_EXT) && M_EXT_WRITABLE(m) ) { > m->m_nextpkt = my_pool; > m->m_data = ->m_ext.ext_buf; > m->m_len = m->m_pkthdr.len = MCLBYTES; > my_pool = m; > my_pool_now++; > } else { > ... rest of m_freem() ... > } > > and save a lot of overhead (we just need to reset m_data and > m_len and m_pkthdr.len) when someone wants to allocate them. > > Is there interest in committing some code like this to > mbuf.h and maybe uipc_mbuf*.c ? Sounds good to me. -- Andre To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message