]> git.puffer.fish Git - mirror/frr.git/commit
zebra: Reorg `struct route_entry` to have important bits first 15309/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 5 Feb 2024 19:15:29 +0000 (14:15 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 5 Feb 2024 19:17:55 +0000 (14:17 -0500)
commit56e62d88c52af87c35c6afa638c56984ec50299c
treedcf5f8cfd03a4f888d7c4f0e4ad2aed470df9148
parentcac925f005d090339dcde74e8770e25dcf29d5c9
zebra: Reorg `struct route_entry` to have important bits first

The `struct route_entry` had items that were almost never used at
the front of the data structure resulting in items that would be
loaded first into memory that were never used.  Let's reorg a
tiny bit and put all the frequently used items in the first cache
line.  I'm sure people will notice .000000001 speedup

new layout:

sharpd@eva /w/h/s/frr1 (reorg_route_entry)> /home/sharpd/pahole/build/pahole --reorganize --show_reorg_steps -C route_entry zebra/.libs/zebra
struct route_entry {
struct re_list_item        next;                 /*     0     8 */
struct nhg_hash_entry *    nhe;                  /*     8     8 */
uint32_t                   nhe_id;               /*    16     4 */
uint32_t                   nhe_installed_id;     /*    20     4 */
int                        type;                 /*    24     4 */
vrf_id_t                   vrf_id;               /*    28     4 */
uint32_t                   table;                /*    32     4 */
uint32_t                   metric;               /*    36     4 */
uint32_t                   mtu;                  /*    40     4 */
uint32_t                   nexthop_mtu;          /*    44     4 */
uint32_t                   flags;                /*    48     4 */
uint32_t                   status;               /*    52     4 */
uint32_t                   dplane_sequence;      /*    56     4 */
uint16_t                   instance;             /*    60     2 */
uint8_t                    distance;             /*    62     1 */

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

/* --- cacheline 1 boundary (64 bytes) --- */
route_tag_t                tag;                  /*    64     4 */

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

time_t                     uptime;               /*    72     8 */
struct re_opaque *         opaque;               /*    80     8 */
struct nexthop_group       fib_ng;               /*    88    32 */
struct nexthop_group       fib_backup_ng;        /*   120    32 */

/* size: 152, cachelines: 3, members: 20 */
/* sum members: 147, holes: 2, sum holes: 5 */
/* last cacheline: 24 bytes */
};

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/rib.h