From 2180baccc1428ffbd64a8312f3c983791a0771ab Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 10 May 2019 15:25:10 -0400 Subject: Preallocate mhash key_tmps vector Fix os_get_nthreads() so that it starts returning the correct answer as early as possible. Change-Id: Id5292262f2c3f521b07ffbe6a9f6748dcc4dcb7d Signed-off-by: Dave Barach --- src/vppinfra/mhash.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/mhash.c b/src/vppinfra/mhash.c index d4d5457ea7a..791aa36024b 100644 --- a/src/vppinfra/mhash.c +++ b/src/vppinfra/mhash.c @@ -205,13 +205,7 @@ mhash_init (mhash_t * h, uword n_value_bytes, uword n_key_bytes) clib_memset (h, 0, sizeof (h[0])); h->n_key_bytes = n_key_bytes; -#if 0 - if (h->n_key_bytes > 0) - { - vec_validate (h->key_tmp, h->n_key_bytes - 1); - _vec_len (h->key_tmp) = 0; - } -#endif + vec_validate (h->key_tmps, os_get_nthreads () - 1); ASSERT (n_key_bytes < ARRAY_LEN (t)); h->hash = hash_create2 ( /* elts */ 0, @@ -228,7 +222,6 @@ mhash_set_tmp_key (mhash_t * h, const void *key) u8 *key_tmp; int my_cpu = os_get_thread_index (); - vec_validate (h->key_tmps, my_cpu); key_tmp = h->key_tmps[my_cpu]; vec_reset_length (key_tmp); -- cgit 1.2.3-korg