socket: Speed up soclose by avoiding putting the user thread into sleep
- Embed a netmsg_base into socket, it will be used if fast soclose
is possible
- Factor out sodiscard(), which abort the connections on the listen
socket and set the SS_NOFDREF bit. This function is shared across
fast soclose and synchronized soclose
- Rename the original soclose() to soclose_sync(), which uses domsg
to perform proto-specific operation
- If kern.ipc.soclose_fast is 1 (it is 1 by default) and SO_LINGER
socket option is not set and the socket does not use synchronized
msgport (e.g. UNIX domain socket), fast soclose will be used
- The fast soclose is implemented to avoid putting the caller thread
(usually a user thread) into sleep. It uses the socket's embeded
"close message" with different dispatch functions based on the
current socket state and send the "close message" (asynchronized)
to proto thread to carry out various tasks.
The result:
On Phenom 9550 (4 core, 2.2GHz):
route change -host 127.0.0.1 -msl 50 (set MSL to 50ms)
8 parallel netperf -H 127.0.0.1 -t TCP_CC -P0 (4 runs, unit: tps)
old 33181.18 33005.66 33130.48 33010.50
new 39109.07 39032.48 39022.75 38993.72
This gives 18% performance improvement