kernel - Improve TCP socket handling at high speeds
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 16 Jul 2014 03:27:51 +0000 (20:27 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 16 Jul 2014 03:27:51 +0000 (20:27 -0700)
commit11b81f5d7090a4c01df8c0e17a07b3a3d89b32be
tree24087e13bdd899000a53fb2a143b7d92895ce372
parent686a02f19a2bddfc339ea4135df3d3eecab0d23c
kernel - Improve TCP socket handling at high speeds

* Add M_SOLOCKED to mbuf->m_flags.  This flag prevents sbcompress()
  from collapsing more data into a mbuf.

* Rewrite sorecvtcp() (NOTE: soreceive() could use similar treatment).
  Use M_SOLOCKED to freeze mbufs in the sockbuf with the rcvtok held,
  then do the uiomove() loop WITHOUT the rcvtok held, then finalize
  the disposal of the mbufs with rcvtok held.

  This greatly reduces contention on rcvtok against the netisr threads
  when reading large amounts of data at once and reduces cpu overhead
  for netisr and user network threads.

* Change the default transmit ssb_lowat from ssb_hiwat / 2 to ssb_hiwat / 4.
  The (previous) default maximum socket buffer size was 256KB.  The default
  lowat reduced the effective TCP transmit window to ~100KB.  This can cause
  severe buffering issues on GiGE links when multiple TCP streams are being
  routed to the same cpu.

  With this change the default max send buffer is ~180KB or so.

* Change the default kern.ipc.maxsockbuf from 256KB to 512KB.  This
  primarily effects auto-sizing of tcp buffers which in turn effects
  most TCP connections.

  This coupled with the hiwat fix greatly improves transmit throughput.

* Add more debugging info to the tcp inflight code.
sys/kern/uipc_sockbuf.c
sys/kern/uipc_socket.c
sys/kern/uipc_socket2.c
sys/netinet/tcp_subr.c
sys/sys/mbuf.h
sys/sys/sockbuf.h