]> git.puffer.fish Git - matthieu/frr.git/commit
bgpd: Optimize memory usage for attr struct
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 29 Jan 2024 13:56:07 +0000 (15:56 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 30 Jan 2024 06:12:58 +0000 (08:12 +0200)
commit4821e7a0d88ce1a70c1a27398b040817e5941238
tree33b41c92f17ea466ddae65ad9093b0f3b3715ea2
parent89e124f042f514b5ce0e3dc39796613152e225b8
bgpd: Optimize memory usage for attr struct

```
struct attr {
struct aspath *            aspath;               /*     0     8 */
struct community *         community;            /*     8     8 */
long unsigned int          refcnt;               /*    16     8 */
_uint64_t                  flag;                 /*    24     8 */
struct in_addr             nexthop;              /*    32     4 */
uint32_t                   med;                  /*    36     4 */
uint32_t                   local_pref;           /*    40     4 */
ifindex_t                  nh_ifindex;           /*    44     4 */
uint8_t                    origin;               /*    48     1 */
uint8_t                    es_flags;             /*    49     1 */
uint8_t                    router_flag;          /*    50     1 */
uint8_t                    default_gw;           /*    51     1 */
enum pta_type              pmsi_tnl_type;        /*    52     4 */
uint32_t                   rmap_change_flags;    /*    56     4 */
struct in6_addr            mp_nexthop_global;    /*    60    16 */
/* --- cacheline 1 boundary (64 bytes) was 12 bytes ago --- */
struct in6_addr            mp_nexthop_local;     /*    76    16 */
ifindex_t                  nh_lla_ifindex;       /*    92     4 */
struct ecommunity *        ecommunity;           /*    96     8 */
struct ecommunity *        ipv6_ecommunity;      /*   104     8 */
struct lcommunity *        lcommunity;           /*   112     8 */
struct cluster_list *      cluster1;             /*   120     8 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct transit *           transit;              /*   128     8 */
struct in_addr             mp_nexthop_global_in; /*   136     4 */
struct in_addr             aggregator_addr;      /*   140     4 */
struct in_addr             originator_id;        /*   144     4 */
uint32_t                   weight;               /*   148     4 */
as_t                       aggregator_as;        /*   152     4 */
uint8_t                    mp_nexthop_len;       /*   156     1 */
uint8_t                    mp_nexthop_prefer_global; /*   157     1 */
uint8_t                    sticky;               /*   158     1 */
uint8_t                    distance;             /*   159     1 */
uint16_t                   encap_tunneltype;     /*   160     2 */
uint8_t                    df_alg;               /*   162     1 */

/* XXX 1 byte hole, try to pack */

route_tag_t                tag;                  /*   164     4 */
uint32_t                   label_index;          /*   168     4 */
mpls_label_t               label;                /*   172     4 */
struct bgp_attr_srv6_vpn * srv6_vpn;             /*   176     8 */
struct bgp_attr_srv6_l3vpn * srv6_l3vpn;         /*   184     8 */
/* --- cacheline 3 boundary (192 bytes) --- */
struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
struct bgp_route_evpn      evpn_overlay;         /*   208    36 */
uint32_t                   mm_seqnum;            /*   244     4 */
uint32_t                   mm_sync_seqnum;       /*   248     4 */
struct ethaddr             rmac;                 /*   252     6 */
/* --- cacheline 4 boundary (256 bytes) was 2 bytes ago --- */
uint16_t                   df_pref;              /*   258     2 */
uint32_t                   rmap_table_id;        /*   260     4 */
uint32_t                   link_bw;              /*   264     4 */
esi_t                      esi;                  /*   268    10 */

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

uint32_t                   srte_color;           /*   280     4 */
uint32_t                   otc;                  /*   284     4 */
enum nexthop_types_t       nh_type;              /*   288     4 */
enum blackhole_type        bh_type;              /*   292     4 */
_uint64_t                  aigp_metric;          /*   296     8 */

/* size: 304, cachelines: 5, members: 53 */
/* sum members: 301, holes: 2, sum holes: 3 */
/* last cacheline: 48 bytes */
};   /* saved 16 bytes! */
```

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