]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Optimize memory for bgp_nexthop_cache struct
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 9 Feb 2024 15:25:05 +0000 (17:25 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 9 Feb 2024 15:25:05 +0000 (17:25 +0200)
```
struct bgp_nexthop_cache {
afi_t                      afi;                  /*     0     4 */
ifindex_t                  ifindex_ipv6_ll;      /*     4     4 */
struct bgp_nexthop_cache_item entry;             /*     8    32 */
uint32_t                   metric;               /*    40     4 */
uint8_t                    nexthop_num;          /*    44     1 */
_Bool                      is_evpn_gwip_nexthop; /*    45     1 */
uint16_t                   change_flags;         /*    46     2 */
struct nexthop *           nexthop;              /*    48     8 */
time_t                     last_update;          /*    56     8 */
/* --- cacheline 1 boundary (64 bytes) --- */
uint16_t                   flags;                /*    64     2 */

/* XXX 2 bytes hole, try to pack */

uint32_t                   srte_color;           /*    68     4 */
struct bgp_nexthop_cache_head * tree;            /*    72     8 */
struct prefix              prefix __attribute__((__aligned__(8))); /*    80    56 */
/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
void *                     nht_info;             /*   136     8 */
struct path_list           paths;                /*   144     8 */
unsigned int               path_count;           /*   152     4 */

/* XXX 4 bytes hole, try to pack */

struct bgp *               bgp;                  /*   160     8 */

/* size: 168, cachelines: 3, members: 17 */
/* sum members: 162, holes: 2, sum holes: 6 */
/* forced alignments: 1 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));   /* saved 16 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_nexthop.h

index 90e0074e358d49162291a5aeb1eebe6b19564a58..830883872e77bd06edb1819d53710836c7a2f5db 100644 (file)
@@ -39,6 +39,18 @@ struct bgp_nexthop_cache {
 
        /* Nexthop number and nexthop linked list.*/
        uint8_t nexthop_num;
+
+       /* This flag is set to TRUE for a bnc that is gateway IP overlay index
+        * nexthop.
+        */
+       bool is_evpn_gwip_nexthop;
+
+       uint16_t change_flags;
+#define BGP_NEXTHOP_CHANGED          (1 << 0)
+#define BGP_NEXTHOP_METRIC_CHANGED    (1 << 1)
+#define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
+#define BGP_NEXTHOP_MACIP_CHANGED     (1 << 3)
+
        struct nexthop *nexthop;
        time_t last_update;
        uint16_t flags;
@@ -72,27 +84,16 @@ struct bgp_nexthop_cache {
  */
 #define BGP_NEXTHOP_EVPN_INCOMPLETE (1 << 7)
 
-       uint16_t change_flags;
-
-#define BGP_NEXTHOP_CHANGED           (1 << 0)
-#define BGP_NEXTHOP_METRIC_CHANGED    (1 << 1)
-#define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
-#define BGP_NEXTHOP_MACIP_CHANGED (1 << 3)
+       uint32_t srte_color;
 
        /* Back pointer to the cache tree this entry belongs to. */
        struct bgp_nexthop_cache_head *tree;
 
-       uint32_t srte_color;
        struct prefix prefix;
        void *nht_info; /* In BGP, peer session */
        LIST_HEAD(path_list, bgp_path_info) paths;
        unsigned int path_count;
        struct bgp *bgp;
-
-       /* This flag is set to TRUE for a bnc that is gateway IP overlay index
-        * nexthop.
-        */
-       bool is_evpn_gwip_nexthop;
 };
 
 extern int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache *a,