git: tcp: Implement random initial msgport

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Wed Aug 28 22:28:11 PDT 2013


commit 1c92f416ac0f54e65f9410f71f4a4e4e0a3e72f3
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Wed Aug 28 15:11:43 2013 +0800

    tcp: Implement random initial msgport
    
    After e368a6e95e2cd9556a3e0fc43167d2dcf3a8253f, it is found that the
    left bottle neck of nonblocking TCP connect(2) performance is that all
    socket(2) and initial TCP connect operation (bind laddr and lport) are
    all carried out in netisr0; CPU0 is 100% busy during test.
    
    The idea of random initial msgport for TCP is that instead of using
    netisr0's msgport as initial msgport, we could use any of the available
    netisr msgport to carry out socket(2) and initial TCP connect operation.
    
    Most of parts of TCP are already ready for random initial msgport, only
    TCP pru_listen requires trivial modification to fix the socket msgport
    to netisr0's msgport (which is required to perform global wild hashtable
    updating).
    
    As of this commit, the current CPU's netisr msgport will be selected as
    TCP socket's initial msgport, if random initial msgport is enabled.
    
    Sysctl node kern.ipc.rand_initport is added to disable this optimization.
    It is enabled by default.
    
    This commit improves both nonblocking TCP connect(2) and blocking TCP
    connect(2) performance.
    
    Nonblocking connect(2) 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)
    
    16 run average:
        random initial msgport          netisr0 msgport
          263915.17 conns/s            220979.89 conns/s
    
    This commit gives ~19% performance improvement for nonblocking connect(2)
    
    Blocking connect(2) performance measurement (i7-2600 w/ bnx(4)), using
    tools/tools/netrate/accept_connect/connect_client:
    
        connect_client -4 SERVADDR -p SERVPORT -i 256 -l 30
        (256 processes)
    
    16 run average:
        random initial msgport          netisr0 msgport
          240235.23 conns/s            198312.87 conns/s
    
    This commit gives ~21% performance improvement for blocking connect(2)

Summary of changes:
 sys/kern/uipc_msg.c      |  1 +
 sys/kern/uipc_socket.c   | 14 ++++++++++++--
 sys/net/netmsg.h         |  3 +++
 sys/netinet/in_proto.c   |  3 ++-
 sys/netinet/tcp_usrreq.c | 26 ++++++++++++++++++++++----
 sys/sys/protosw.h        |  1 +
 6 files changed, 41 insertions(+), 7 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/1c92f416ac0f54e65f9410f71f4a4e4e0a3e72f3


-- 
DragonFly BSD source repository


More information about the Commits mailing list