cnat: remove rwlock on ts

Type: improvement

Remove rwlock contention on timestamps. ~10% pps with
10k sessions. Use fixed-size-pools of increasing sizes
starting with 4K, and with a x2 step each time.
We don't free/shrink allocated pools.

Change-Id: I5fea51faba40430106c823275a6356e81709d118
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
This commit is contained in:
Nathan Skrzypczak
2020-11-04 11:41:05 +01:00
committed by Beno�t Ganne
parent 897844d1e9
commit 6d733a93b2
7 changed files with 133 additions and 61 deletions
+18 -5
View File
@@ -148,9 +148,6 @@ typedef struct cnat_main_
/* delay in seconds between two scans of session/clients tables */
f64 scanner_timeout;
/* Lock for the timestamp pool */
clib_rwlock_t ts_lock;
/* Index of the scanner process node */
uword scanner_node_index;
@@ -175,6 +172,23 @@ typedef struct cnat_timestamp_t_
u16 refcnt;
} cnat_timestamp_t;
/* Create the first pool with 1 << CNAT_TS_BASE_SIZE elts */
#define CNAT_TS_BASE_SIZE (8)
/* reserve the top CNAT_TS_MPOOL_BITS bits for finding the pool */
#define CNAT_TS_MPOOL_BITS (6)
typedef struct cnat_timestamp_mpool_t_
{
/* Increasing fixed size pools of timestamps */
cnat_timestamp_t *ts_pools[1 << CNAT_TS_MPOOL_BITS];
/* Bitmap of pools with free space */
uword *ts_free;
/* Index of next pool to init */
u8 next_empty_pool_idx;
/* ts creation lock */
clib_spinlock_t ts_lock;
} cnat_timestamp_mpool_t;
typedef struct cnat_node_ctx_
{
f64 now;
@@ -188,8 +202,7 @@ extern u8 *format_cnat_endpoint (u8 * s, va_list * args);
extern uword unformat_cnat_ep_tuple (unformat_input_t * input,
va_list * args);
extern uword unformat_cnat_ep (unformat_input_t * input, va_list * args);
extern cnat_timestamp_t *cnat_timestamps;
extern fib_source_t cnat_fib_source;
extern cnat_timestamp_mpool_t cnat_timestamps;
extern cnat_main_t cnat_main;
extern char *cnat_error_strings[];