summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/test_bihash_template.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-05-17 20:20:50 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2017-05-18 15:38:52 +0000
commitba7ddfe9b77771c47f99df5475e6e92b8d80816e (patch)
tree3c04fc256af5828fbaf1934bb2f91ae7daadbbee /src/vppinfra/test_bihash_template.c
parent287ca3c9162456a93380f55090354e3ce0e7cb2f (diff)
VPP-847: improve bihash template memory allocator performance
Particularly in the DCLIB_VEC64=1 case, using vectors vs. raw clib_mem_alloc'ed memory causes abysmal memory allocator performance. Change-Id: I07a4dec0cd69ca357445385e2671cdf23c59b95d Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/test_bihash_template.c')
-rw-r--r--src/vppinfra/test_bihash_template.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/vppinfra/test_bihash_template.c b/src/vppinfra/test_bihash_template.c
index ef03f565e1d..1e262430803 100644
--- a/src/vppinfra/test_bihash_template.c
+++ b/src/vppinfra/test_bihash_template.c
@@ -48,6 +48,43 @@ vl (void *v)
}
static clib_error_t *
+test_bihash_vec64 (test_main_t * tm)
+{
+ u32 user_buckets = 1228800;
+ u32 user_memory_size = 209715200;
+ BVT (clib_bihash_kv) kv;
+ int i, j;
+ f64 before;
+ f64 *cum_times = 0;
+ BVT (clib_bihash) * h;
+
+ h = &tm->hash;
+
+ BV (clib_bihash_init) (h, "test", user_buckets, user_memory_size);
+
+ before = clib_time_now (&tm->clib_time);
+
+ for (j = 0; j < 10; j++)
+ {
+ for (i = 1; i <= j * 1000 + 1; i++)
+ {
+ kv.key = i;
+ kv.value = 1;
+
+ BV (clib_bihash_add_del) (h, &kv, 1 /* is_add */ );
+ }
+
+ vec_add1 (cum_times, clib_time_now (&tm->clib_time) - before);
+ }
+
+ for (j = 0; j < vec_len (cum_times); j++)
+ fformat (stdout, "Cum time for %d: %.4f (us)\n", (j + 1) * 1000,
+ cum_times[j] * 1e6);
+
+ return 0;
+}
+
+static clib_error_t *
test_bihash (test_main_t * tm)
{
int i, j;
@@ -204,6 +241,7 @@ test_bihash_main (test_main_t * tm)
{
unformat_input_t *i = tm->input;
clib_error_t *error;
+ int test_vec64 = 0;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
@@ -222,6 +260,8 @@ test_bihash_main (test_main_t * tm)
;
else if (unformat (i, "search %d", &tm->search_iter))
;
+ else if (unformat (i, "vec64"))
+ test_vec64 = 1;
else if (unformat (i, "verbose"))
tm->verbose = 1;
else
@@ -229,7 +269,10 @@ test_bihash_main (test_main_t * tm)
format_unformat_error, i);
}
- error = test_bihash (tm);
+ if (test_vec64)
+ error = test_bihash_vec64 (tm);
+ else
+ error = test_bihash (tm);
return error;
}