git: tcp: Implement asynchronous pru_connect

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Tue Aug 27 22:03:57 PDT 2013


commit e368a6e95e2cd9556a3e0fc43167d2dcf3a8253f
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Tue Aug 20 20:52:35 2013 +0800

    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)

Summary of changes:
 sys/kern/uipc_msg.c                                | 45 +++++++++++++++-
 sys/kern/uipc_socket.c                             | 12 ++++-
 sys/kern/uipc_syscalls.c                           |  3 +-
 sys/net/netisr.c                                   |  8 +++
 sys/net/netmsg.h                                   | 14 ++---
 sys/netgraph/ksocket/ng_ksocket.c                  |  2 +-
 .../bluetooth/socket/ng_btsocket_rfcomm.c          |  2 +-
 sys/netgraph7/ksocket/ng_ksocket.c                 |  2 +-
 sys/netinet/in_proto.c                             |  4 +-
 sys/netinet/tcp_usrreq.c                           | 62 +++++++++++++++++-----
 sys/netinet/udp_usrreq.c                           |  6 +--
 sys/netproto/ncp/ncp_sock.c                        |  2 +-
 sys/netproto/smb/smb_trantcp.c                     |  2 +-
 sys/sys/protosw.h                                  | 11 ++++
 sys/sys/socketops.h                                |  2 +
 sys/sys/socketvar.h                                |  3 +-
 sys/vfs/nfs/nfs_socket.c                           |  2 +-
 17 files changed, 146 insertions(+), 36 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e368a6e95e2cd9556a3e0fc43167d2dcf3a8253f


-- 
DragonFly BSD source repository


More information about the Commits mailing list