diff options
author | Damjan Marion <damarion@cisco.com> | 2021-09-20 17:12:03 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2021-09-20 17:44:10 +0200 |
commit | a9f5f85c95dbb0d05a5fa6a31847b50b511e5156 (patch) | |
tree | 7bb8198aace808fe83857a0f73288442c54e53c6 /src/vnet | |
parent | 3bb2da9cb115a489061ffb70332ac0801ce2551b (diff) |
classify: improve find entry performance
Type: improvement
Change-Id: I5245fc3f35b7a70833916db2ebf33f7c87398915
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/classify/vnet_classify.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/vnet/classify/vnet_classify.h b/src/vnet/classify/vnet_classify.h index 196a24172cc..11b05308b19 100644 --- a/src/vnet/classify/vnet_classify.h +++ b/src/vnet/classify/vnet_classify.h @@ -408,9 +408,7 @@ vnet_classify_find_entry_inline (vnet_classify_table_t *t, const u8 *h, u64 as_u64[2]; } result __attribute__ ((aligned (sizeof (u32x4)))); vnet_classify_bucket_t *b; - u32 value_index; - u32 bucket_index; - u32 limit; + u32 bucket_index, limit, pages; int i; bucket_index = hash & (t->nbuckets - 1); @@ -420,18 +418,19 @@ vnet_classify_find_entry_inline (vnet_classify_table_t *t, const u8 *h, if (b->offset == 0) return 0; - hash >>= t->log2_nbuckets; - + pages = 1 << b->log2_pages; v = vnet_classify_get_entry (t, b->offset); - value_index = hash & ((1 << b->log2_pages) - 1); limit = t->entries_per_page; if (PREDICT_FALSE (b->linear_search)) { - value_index = 0; - limit *= (1 << b->log2_pages); + limit *= pages; + v = vnet_classify_entry_at_index (t, v, 0); + } + else + { + hash >>= t->log2_nbuckets; + v = vnet_classify_entry_at_index (t, v, hash & (pages - 1)); } - - v = vnet_classify_entry_at_index (t, v, value_index); #ifdef CLIB_HAVE_VEC128 const u32x4u *data = (const u32x4u *) h; |