summaryrefslogtreecommitdiff
path: root/memcached.h
diff options
context:
space:
mode:
authorSridhar Samudrala <sridhar.samudrala@intel.com>2020-08-18 23:53:07 -0700
committerdormando <dormando@rydia.net>2020-11-02 15:00:36 -0800
commit4de258ed891c0e5048192be1626fff6fabb10438 (patch)
tree72d641c7d3cf7fe74817f229fed164342cfa41ff /memcached.h
parent0b374c63ab7e63c0098983d0a68cefedfd94557a (diff)
downloadmemcached-4de258ed891c0e5048192be1626fff6fabb10438.tar.gz
Introduce NAPI ID based worker thread selection
By default memcached assigns connections to worker threads in a round-robin manner. This patch introduces an option to select a worker thread based on the incoming connection's NAPI ID if SO_INCOMING_NAPI_ID socket option is supported by the OS. This allows a memcached worker thread to be associated with a NIC HW receive queue and service all the connection requests received on a specific RX queue. This mapping between a memcached thread and a HW NIC queue streamlines the flow of data from the NIC to the application. In addition, an optimal path with reduced context switches is possible, if epoll based busy polling (sysctl -w net.core.busy_poll = <non-zero value>) is also enabled. This feature is enabled via a new command line parameter -N <num> or "--napi_ids=<num>", where <num> is the number of available/assigned NIC hardware RX queues through which the connections can be received. The number of napi_ids specified cannot be greater than the number of worker threads specified using -t/--threads option. If the option is not specified, or the conditions not met, the code defaults to round robin thread selection. Signed-off-by: Kiran Patil <kiran.patil@intel.com> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Diffstat (limited to 'memcached.h')
-rw-r--r--memcached.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/memcached.h b/memcached.h
index 2eb9ebb..17d2a8f 100644
--- a/memcached.h
+++ b/memcached.h
@@ -367,6 +367,8 @@ struct stats {
uint64_t ssl_new_sessions; /* successfully negotiated new (non-reused) TLS sessions */
#endif
struct timeval maxconns_entered; /* last time maxconns entered */
+ uint64_t unexpected_napi_ids; /* see doc/napi_ids.txt */
+ uint64_t round_robin_fallback; /* see doc/napi_ids.txt */
};
/**
@@ -481,6 +483,7 @@ struct settings {
unsigned int ssl_wbuf_size; /* size of the write buffer used by ssl_sendmsg method */
bool ssl_session_cache; /* enable SSL server session caching */
#endif
+ int num_napi_ids; /* maximum number of NAPI IDs */
};
extern struct stats stats;
@@ -621,6 +624,7 @@ typedef struct {
#ifdef TLS
char *ssl_wbuf;
#endif
+ int napi_id; /* napi id associated with this thread */
} LIBEVENT_THREAD;