tcp: Implement asynchronous pru_connect
This is mainly used to improve TCP nonblocking connect(2) performance.
Before this commit the user space thread uses nonblocking connect(2)
will have to wait for the netisr completes the SYN output. This could
be performance hit for nonblocking connect(2). First, the user space
thread is put into sleep, even if the connect(2) is nonblocking.
Second, it does not make too much sense for nonblocking connect(2) to
wait for the SYN output.
TCP's asynchronous pru_connect implementation will set ISCONNECTING
before dispatching netmsg to netisr0. The errors like EADDRNOTAVAIL,
i.e. out of local port space, will be notified through kevent(2) or
getsockopt(2) SOL_SOCKET/SO_ERROR.
NFS and other kernel code still use old synchronized pru_connect. This
commit only affects connect(2) syscall.
Sysctl node kern.ipc.soconnect_async is added to enable and disable
asynchronous pru_connect. It is enabled by default.
The performance measurement (i7-2600 w/ bnx(4)), using
tools/tools/netrate/accept_connect/kq_connect_client:
kq_connect_client -4 SERVADDR -p SERVPORT -i 8 -c 32 -l 30
(8 processes, each creates 32 connections simultaniously, run 30 secs)
16 runs average:
asynchronous pru_connect synchronized pru_connect
220979.89 conns/s 189106.88 conns/s
This commit gives ~16% performance improvement for nonblocking connect(2)
17 files changed: