diff options
author | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2020-11-04 11:41:05 +0100 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2023-08-09 08:23:45 +0000 |
commit | 6d733a93b2eb9c16196ee17d5cdc77db21589571 (patch) | |
tree | 7e23016a4ceafedfe85974b58d56a4007780c52b /src/plugins/cnat/cnat_types.h | |
parent | 897844d1e96797f69e3e7e11d237d847fe4e46bf (diff) |
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>
Diffstat (limited to 'src/plugins/cnat/cnat_types.h')
-rw-r--r-- | src/plugins/cnat/cnat_types.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/cnat/cnat_types.h b/src/plugins/cnat/cnat_types.h index abae83af59a..d229d21adae 100644 --- a/src/plugins/cnat/cnat_types.h +++ b/src/plugins/cnat/cnat_types.h @@ -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[]; |