git: DragonFly_RELEASE_5_0 socket: Limit the number of accepted sockets that kevent reports.

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Thu Oct 5 07:21:37 PDT 2017


commit 5fcc484ea290d8d3f6c0a15ea6bbce166ddf6dbf
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Thu Oct 5 14:06:11 2017 +0800

    socket: Limit the number of accepted sockets that kevent reports.
    
    By default it is limited to 32.  It can be changed through:
    sysctl kern.ipc.soavailconn=X
    
    This change does _not_ affect userland using accept(2) in the following
    way:
        for (;;) {
            s = accept();
            if (s < 0 && errno == EAGAIN)
                break;
            /* Processing accepted socket. */
        }
    
    This change only affects optimized userland using kevent.data to avoid
    extra accept(2) syscall:
        for (i = 0; i < kevent.data; ++i) {
            s = accept();
            /* Processing accepted socket. */
        }
    
    The above logic is applied by nginx.  However, due to the cost of the
    "Processing accepted socket" parts, this kinda of loop can increase
    latency and destablize latency.
    
    The comparison w/ 30K concurrent connections, 1 request/connection.
    
     1K web object
             |  performance |  lat-avg | lat-stdev |  lat-99%
    ---------+--------------+----------+-----------+----------
    no limit | 210279.88tps |  59.19ms |    4.60ms |  69.02ms
    ---------+--------------+----------+-----------+----------
    32 limit | 217599.01tps |  32.00ms |    2.35ms |  35.59ms
    
    ========
    
     8K web object
             |  performance |  lat-avg | lat-stdev |  lat-99%
    ---------+--------------+----------+-----------+----------
    no limit | 180627.61tps |  70.53ms |    4.95ms |  80.61ms
    ---------+--------------+----------+-----------+----------
    32 limit | 186324.41tps |  37.41ms |    4.81ms |  48.69ms
    
    ========
    
    16K web object
             |  performance |  lat-avg | lat-stdev |  lat-99%
    ---------+--------------+----------+-----------+----------
    no limit | 138667.84tps |  95.93ms |   14.90ms | 135.47ms
    ---------+--------------+----------+-----------+----------
    32 limit | 138778.11tps |  60.90ms |   11.80ms |  92.07ms
    
    This change significantly reduces average latency and .99 latency,
    and performance is improved slightly.

Summary of changes:
 sys/kern/uipc_socket.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/5fcc484ea290d8d3f6c0a15ea6bbce166ddf6dbf


-- 
DragonFly BSD source repository


More information about the Commits mailing list