diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2002-08-08 17:07:33 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2002-08-08 17:07:33 +0000 |
commit | 645bfcfc7a44cb3eef794f55a0f348cdbb48b20c (patch) | |
tree | 65348cbbc69a068876bfe2a31a3287f71b482d02 /sys/netccitt | |
parent | 3ab868adf3b73fcb169a2f03c12e12d299f6f672 (diff) |
socket buf speedup from thorpej@netbsd, okay art@ ericj@:
Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream(). On a profiling
run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time. Thanks
to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!
Diffstat (limited to 'sys/netccitt')
-rw-r--r-- | sys/netccitt/if_x25subr.c | 10 | ||||
-rw-r--r-- | sys/netccitt/pk_output.c | 5 | ||||
-rw-r--r-- | sys/netccitt/pk_usrreq.c | 3 |
3 files changed, 13 insertions, 5 deletions
diff --git a/sys/netccitt/if_x25subr.c b/sys/netccitt/if_x25subr.c index 7a9ca11329b..ad7e23c6f9a 100644 --- a/sys/netccitt/if_x25subr.c +++ b/sys/netccitt/if_x25subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_x25subr.c,v 1.10 2002/03/14 01:27:10 millert Exp $ */ +/* $OpenBSD: if_x25subr.c,v 1.11 2002/08/08 17:07:32 provos Exp $ */ /* $NetBSD: if_x25subr.c,v 1.13 1996/05/09 22:29:25 scottr Exp $ */ /* @@ -771,7 +771,13 @@ pk_rtattach(so, m0) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #define transfer_sockbuf(s, f, l) \ while ((m = (s)->sb_mb) != NULL) \ - {(s)->sb_mb = m->m_act; m->m_act = 0; sbfree((s), m); f;} + { \ + (s)->sb_mb = m->m_nextpkt; \ + SB_EMPTY_FIXUP((s)); \ + m->m_nextpkt = 0; \ + sbfree((s), m); \ + f; \ + } if (rt) rt->rt_refcnt--; diff --git a/sys/netccitt/pk_output.c b/sys/netccitt/pk_output.c index 36c58f39643..36eed07cf5b 100644 --- a/sys/netccitt/pk_output.c +++ b/sys/netccitt/pk_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk_output.c,v 1.2 1996/03/04 07:36:43 niklas Exp $ */ +/* $OpenBSD: pk_output.c,v 1.3 2002/08/08 17:07:32 provos Exp $ */ /* $NetBSD: pk_output.c,v 1.7 1996/02/13 22:05:30 christos Exp $ */ /* @@ -212,7 +212,8 @@ nextpk(lcp) return (NULL); sb->sb_mb = m->m_nextpkt; - m->m_act = 0; + SB_EMPTY_FIXUP(sb); + m->m_nextpkt = 0; for (n = m; n; n = n->m_next) sbfree(sb, n); } diff --git a/sys/netccitt/pk_usrreq.c b/sys/netccitt/pk_usrreq.c index c351ddd898c..f60c239a9cc 100644 --- a/sys/netccitt/pk_usrreq.c +++ b/sys/netccitt/pk_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk_usrreq.c,v 1.4 2002/03/14 01:27:10 millert Exp $ */ +/* $OpenBSD: pk_usrreq.c,v 1.5 2002/08/08 17:07:32 provos Exp $ */ /* $NetBSD: pk_usrreq.c,v 1.10 1996/02/13 22:05:43 christos Exp $ */ /* @@ -277,6 +277,7 @@ pk_usrreq(so, req, m, nam, control) if (n && n->m_type == MT_OOBDATA) { unsigned len = n->m_pkthdr.len; so->so_rcv.sb_mb = n->m_nextpkt; + SB_EMPTY_FIXUP(&so->so_rcv); if (len != n->m_len && (n = m_pullup(n, len)) == 0) break; |