From 0d88301a576191a0e330e539cf1dcb3837ee1bf6 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 11 May 2018 11:06:23 -0700 Subject: bond: performance harvesting - hash is great. But it is a bit too slow for the DP. Use direct array indexing to quickly retrieve the slave interface. - the algorithm used by flow hash is great. But it is a bit too slow for the DP. Use l2_hash_hash() extracted from lb_hash.h which ECMP is using. It makes use of intrinsic crc32 instruction set. - shortcut modulo arithmetic when the operand is 2**x (where x up to 4) to avoid division instruction. - special case for link count == 1 in bond_tx_fn() - use clib_mem_unaligned to access data for the packet to avoid alignment error - Fix some typos for packet tracing. Change-Id: I8eae3ad497061c5473aa675ba894ee0211120d25 Signed-off-by: Steven --- src/vnet/bonding/cli.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/vnet/bonding/cli.c') diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c index b66c4af337d..2799bb88b99 100644 --- a/src/vnet/bonding/cli.c +++ b/src/vnet/bonding/cli.c @@ -142,7 +142,7 @@ bond_delete_neighbor (vlib_main_t * vm, bond_if_t * bif, slave_if_t * sif) bif->port_number_bitmap = clib_bitmap_set (bif->port_number_bitmap, ntohs (sif->actor_admin.port_number) - 1, 0); - hash_unset (bm->neighbor_by_sw_if_index, sif->sw_if_index); + bm->slave_by_sw_if_index[sif->sw_if_index] = 0; vec_free (sif->last_marker_pkt); vec_free (sif->last_rx_pkt); vec_foreach_index (i, bif->slaves) @@ -451,8 +451,15 @@ bond_enslave (vlib_main_t * vm, bond_enslave_args_t * args) else sif->ttl_in_seconds = LACP_SHORT_TIMOUT_TIME; - hash_set (bm->neighbor_by_sw_if_index, sif->sw_if_index, - sif - bm->neighbors); + vec_validate_aligned (bm->slave_by_sw_if_index, sif->sw_if_index, + CLIB_CACHE_LINE_BYTES); + /* + * sif - bm->neighbors may be 0 + * Left shift it by 1 bit to distinguish the valid entry that we actually + * store from the null entries + */ + bm->slave_by_sw_if_index[sif->sw_if_index] = + (uword) (((sif - bm->neighbors) << 1) | 1); vec_add1 (bif->slaves, sif->sw_if_index); sif_hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index); @@ -726,7 +733,7 @@ bond_cli_init (vlib_main_t * vm) bm->vlib_main = vm; bm->vnet_main = vnet_get_main (); - bm->neighbor_by_sw_if_index = hash_create (0, sizeof (uword)); + vec_validate_aligned (bm->slave_by_sw_if_index, 1, CLIB_CACHE_LINE_BYTES); return 0; } -- cgit 1.2.3-korg