aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/test_bihash_template.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-04-16 12:00:14 -0400
committerDamjan Marion <dmarion@me.com>2020-04-21 10:26:14 +0000
commit16e4a4a0ae39ebc1ded1b6dba2799b176aee1828 (patch)
tree14e21d5be2bb77b9301b5cb56118e3e9d8293811 /src/vppinfra/test_bihash_template.c
parentb9753540d2a69bbab807653fc3d0c1b43ec4d6d5 (diff)
vppinfra: bihash improvements
Template instances can allocate BIHASH_KVP_PER_PAGE data records tangent to the bucket, to remove a dependent read / prefetch. Template instances can ask for immediate memory allocation, to avoid several branches in the lookup path. Clean up l2 fib, gpb plugin codes: use clib_bihash_get_bucket(...) Use hugepages for bihash allocation arenas Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Damjan Marion <damarion@cisco.com> Change-Id: I92fc11bc58e48d84e2d61f44580916dd1c56361c
Diffstat (limited to 'src/vppinfra/test_bihash_template.c')
-rw-r--r--src/vppinfra/test_bihash_template.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/vppinfra/test_bihash_template.c b/src/vppinfra/test_bihash_template.c
index c1a44691966..86039d8408a 100644
--- a/src/vppinfra/test_bihash_template.c
+++ b/src/vppinfra/test_bihash_template.c
@@ -337,6 +337,16 @@ test_bihash (test_main_t * tm)
{
for (i = 0; i < tm->nitems; i++)
{
+ /* Prefetch buckets 8 iterations ahead */
+ if (1 && (i < (tm->nitems - 8)))
+ {
+ BVT (clib_bihash_kv) pref_kv;
+ u64 pref_hash;
+ pref_kv.key = tm->keys[i + 8];
+ pref_hash = BV (clib_bihash_hash) (&pref_kv);
+ BV (clib_bihash_prefetch_bucket) (h, pref_hash);
+ }
+
kv.key = tm->keys[i];
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
if (BV (clib_bihash_search) (h, &kv, &kv) < 0)
@@ -356,8 +366,10 @@ test_bihash (test_main_t * tm)
total_searches = (uword) tm->search_iter * (uword) tm->nitems;
if (delta > 0)
- fformat (stdout, "%.f searches per second\n",
- ((f64) total_searches) / delta);
+ fformat (stdout,
+ "%.f searches per second, %.2f nsec per search\n",
+ ((f64) total_searches) / delta,
+ 1e9 * (delta / ((f64) total_searches)));
fformat (stdout, "%lld searches in %.6f seconds\n", total_searches,
delta);
@@ -409,6 +421,16 @@ test_bihash (test_main_t * tm)
{
for (j = 0; j < tm->nitems; j++)
{
+ /* Prefetch buckets 8 iterations ahead */
+ if (1 && (j < (tm->nitems - 8)))
+ {
+ BVT (clib_bihash_kv) pref_kv;
+ u64 pref_hash;
+ pref_kv.key = tm->keys[j + 8];
+ pref_hash = BV (clib_bihash_hash) (&pref_kv);
+ BV (clib_bihash_prefetch_bucket) (h, pref_hash);
+ }
+
kv.key = tm->keys[j];
rv = BV (clib_bihash_search) (h, &kv, &kv);
if (j <= i && rv >= 0)