From 161972c9fe108ffe3de851a537d9b34efeb09e31 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 19 Apr 2023 08:13:18 -0400 Subject: *: Rearrange vrf_bitmap_X api to reduce memory footprint When running all daemons with config for most of them, FRR has sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l 3570 3570 hashes for bitmaps associated with the vrf. This is a very large number of hashes. Let's do two things: a) Reduce the created size of the actually created hashes to 2 instead of 32. b) Delay generation of the hash *until* a set operation happens. As that no hash directly implies a unset value if/when checked. This reduces the number of hashes to 61 in my setup for normal operation. Signed-off-by: Donald Sharp --- zebra/zapi_msg.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'zebra/zapi_msg.c') diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index b91e2ec74..5ac875405 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -995,7 +995,7 @@ void zsend_nhrp_neighbor_notify(int cmd, struct interface *ifp, family2addrsize(sockunion_family(&ip))); for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) { - if (!vrf_bitmap_check(client->nhrp_neighinfo[afi], + if (!vrf_bitmap_check(&client->nhrp_neighinfo[afi], ifp->vrf->vrf_id)) continue; @@ -1016,7 +1016,7 @@ int zsend_router_id_update(struct zserv *client, afi_t afi, struct prefix *p, struct stream *s; /* Check this client need interface information. */ - if (!vrf_bitmap_check(client->ridinfo[afi], vrf_id)) + if (!vrf_bitmap_check(&client->ridinfo[afi], vrf_id)) return 0; s = stream_new(ZEBRA_MAX_PACKET_SIZ); @@ -2281,7 +2281,7 @@ static void zread_router_id_add(ZAPI_HANDLER_ARGS) } /* Router-id information is needed. */ - vrf_bitmap_set(client->ridinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_set(&client->ridinfo[afi], zvrf_id(zvrf)); router_id_get(afi, &p, zvrf); @@ -2317,7 +2317,7 @@ static void zread_router_id_delete(ZAPI_HANDLER_ARGS) goto stream_failure; } - vrf_bitmap_unset(client->ridinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_unset(&client->ridinfo[afi], zvrf_id(zvrf)); stream_failure: return; @@ -2407,10 +2407,11 @@ static void zread_vrf_unregister(ZAPI_HANDLER_ARGS) for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (i = 0; i < ZEBRA_ROUTE_MAX; i++) - vrf_bitmap_unset(client->redist[afi][i], zvrf_id(zvrf)); - vrf_bitmap_unset(client->redist_default[afi], zvrf_id(zvrf)); - vrf_bitmap_unset(client->ridinfo[afi], zvrf_id(zvrf)); - vrf_bitmap_unset(client->nhrp_neighinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_unset(&client->redist[afi][i], + zvrf_id(zvrf)); + vrf_bitmap_unset(&client->redist_default[afi], zvrf_id(zvrf)); + vrf_bitmap_unset(&client->ridinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_unset(&client->nhrp_neighinfo[afi], zvrf_id(zvrf)); } } @@ -3563,7 +3564,7 @@ static inline void zebra_neigh_register(ZAPI_HANDLER_ARGS) afi); goto stream_failure; } - vrf_bitmap_set(client->nhrp_neighinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_set(&client->nhrp_neighinfo[afi], zvrf_id(zvrf)); stream_failure: return; } @@ -3579,7 +3580,7 @@ static inline void zebra_neigh_unregister(ZAPI_HANDLER_ARGS) afi); goto stream_failure; } - vrf_bitmap_unset(client->nhrp_neighinfo[afi], zvrf_id(zvrf)); + vrf_bitmap_unset(&client->nhrp_neighinfo[afi], zvrf_id(zvrf)); stream_failure: return; } -- cgit v1.2.3