aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadu Nicolau <radu.nicolau@intel.com>2021-03-16 12:45:01 +0000
committerDamjan Marion <dmarion@me.com>2021-04-06 08:47:17 +0000
commitd82349ecad23bfd80e9a518f595adf78f363c68d (patch)
treec99da64da387a9680c99509b4add4821560037ff
parent8f10b9050dc6318d7ccb3982eec2ed742752c6ea (diff)
buffers: performance improvement
Initialize the local variables as to prevent first fall through one by one processing; skip prefetching rather than doing one by one when count below 12. Type: improvement Signed-off-by: Radu Nicolau <radu.nicolau@intel.com> Change-Id: If02935da081e24f7cfe408811ccf6922cf982092
-rw-r--r--src/vlib/buffer_funcs.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index 95b622c202c..f1be94c61f4 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -786,28 +786,42 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
vlib_buffer_t bt = { };
#if defined(CLIB_HAVE_VEC128)
vlib_buffer_t bpi_mask = {.buffer_pool_index = ~0 };
- vlib_buffer_t bpi_vec = {.buffer_pool_index = ~0 };
+ vlib_buffer_t bpi_vec = {};
vlib_buffer_t flags_refs_mask = {
.flags = VLIB_BUFFER_NEXT_PRESENT,
.ref_count = ~1
};
#endif
+ if (PREDICT_FALSE (n_buffers == 0))
+ return;
+
+ vlib_buffer_t *b = vlib_get_buffer (vm, buffers[0]);
+ buffer_pool_index = b->buffer_pool_index;
+ bp = vlib_get_buffer_pool (vm, buffer_pool_index);
+ vlib_buffer_copy_template (&bt, &bp->buffer_template);
+#if defined(CLIB_HAVE_VEC128)
+ bpi_vec.buffer_pool_index = buffer_pool_index;
+#endif
+
while (n_buffers)
{
vlib_buffer_t *b[8];
u32 bi, sum = 0, flags, next;
- if (n_buffers < 12)
+ if (n_buffers < 4)
goto one_by_one;
vlib_get_buffers (vm, buffers, b, 4);
- vlib_get_buffers (vm, buffers + 8, b + 4, 4);
- vlib_prefetch_buffer_header (b[4], LOAD);
- vlib_prefetch_buffer_header (b[5], LOAD);
- vlib_prefetch_buffer_header (b[6], LOAD);
- vlib_prefetch_buffer_header (b[7], LOAD);
+ if (n_buffers >= 12)
+ {
+ vlib_get_buffers (vm, buffers + 8, b + 4, 4);
+ vlib_prefetch_buffer_header (b[4], LOAD);
+ vlib_prefetch_buffer_header (b[5], LOAD);
+ vlib_prefetch_buffer_header (b[6], LOAD);
+ vlib_prefetch_buffer_header (b[7], LOAD);
+ }
#if defined(CLIB_HAVE_VEC128)
u8x16 p0, p1, p2, p3, r;