Date: Mon, 4 Jun 2012 12:49:22 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r236560 - head/sys/kern Message-ID: <201206041249.q54CnM32042022@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Jun 4 12:49:21 2012 New Revision: 236560 URL: http://svn.freebsd.org/changeset/base/236560 Log: Optimise kern_sendfile(): skip cycling through the entire mbuf chain in m_cat(), storing pointer to last mbuf in chain in local variable and attaching new mbuf to the end of chain. Submitter reports that CPU load dropped for > 10% on a web server serving large files with this optimisation. Submitted by: Sergey Budnevitch <sb nginx.com> Modified: head/sys/kern/uipc_syscalls.c Modified: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Mon Jun 4 12:36:58 2012 (r236559) +++ head/sys/kern/uipc_syscalls.c Mon Jun 4 12:49:21 2012 (r236560) @@ -1962,6 +1962,7 @@ kern_sendfile(struct thread *td, struct * and takes care of the overall progress. */ for (off = uap->offset, rem = uap->nbytes; ; ) { + struct mbuf *mtail = NULL; int loopbytes = 0; int space = 0; int done = 0; @@ -2181,10 +2182,15 @@ retry_space: m0->m_len = xfsize; /* Append to mbuf chain. */ - if (m != NULL) - m_cat(m, m0); - else - m = m0; + if (mtail != NULL) { + mtail->m_next = m0; + } else { + if (m != NULL) + m_cat(m, m0); + else + m = m0; + } + mtail = m0; /* Keep track of bits processed. */ loopbytes += xfsize;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206041249.q54CnM32042022>