aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/main.c
diff options
context:
space:
mode:
authorDave Barach <dbarach@cisco.com>2019-03-10 09:44:51 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-03-10 23:16:43 +0000
commit593eedf2561f639703d366cd21ab0c3ae03bdb0c (patch)
tree75c7ed53b941d46127d1c6b88a16f5936570d2ce /src/vlib/main.c
parentc7886c5d50782b9653ab41772fb93cff0c0ad9da (diff)
Perf tune get_frame_size_info
It turns out that for scalar sizes 0..24, frames are always the same size. That range includes all current use-cases - and then some - so get rid of the hash table. Old code preserved under #ifdef VLIB_SUPPORTS_ARBITRARY_SCALAR_SIZES. Change-Id: Ic005c7143c9639f77d1a0fadd2fc0e90dccb68c1 Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/vlib/main.c')
-rw-r--r--src/vlib/main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index c5cb155b1ee..4dcf63e0f9c 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -91,10 +91,11 @@ vlib_frame_find_magic (vlib_frame_t * f, vlib_node_t * node)
return p;
}
-static vlib_frame_size_t *
+static inline vlib_frame_size_t *
get_frame_size_info (vlib_node_main_t * nm,
u32 n_scalar_bytes, u32 n_vector_bytes)
{
+#ifdef VLIB_SUPPORTS_ARBITRARY_SCALAR_SIZES
uword key = (n_scalar_bytes << 16) | n_vector_bytes;
uword *p, i;
@@ -109,6 +110,11 @@ get_frame_size_info (vlib_node_main_t * nm,
}
return vec_elt_at_index (nm->frame_sizes, i);
+#else
+ ASSERT (vlib_frame_bytes (n_scalar_bytes, n_vector_bytes)
+ == (vlib_frame_bytes (0, 4)));
+ return vec_elt_at_index (nm->frame_sizes, 0);
+#endif
}
static u32