Date: Sat, 29 Jun 2002 14:53:03 -0700 From: Luigi Rizzo <rizzo@icir.org> To: net@freebsd.org Subject: Should we keep a cache of mbuf+cluster ready for use ? Message-ID: <20020629145303.A75543@iguana.icir.org>
next in thread | raw e-mail | index | archive | help
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 ? cheers luigi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020629145303.A75543>