[PATCH] netvsc: optimize stats counters performance
Stephen Hemminger
stephen at networkplumber.org
Fri Aug 2 19:33:24 CEST 2024
On Fri, 2 Aug 2024 19:28:26 +0200
Morten Brørup <mb at smartsharesystems.com> wrote:
> > > ea = rte_pktmbuf_mtod(m, const struct rte_ether_addr *);
> > > - if (rte_is_multicast_ether_addr(ea)) {
> > > - if (rte_is_broadcast_ether_addr(ea))
> > > - stats->broadcast++;
> > > - else
> > > - stats->multicast++;
> > > - }
> > > + RTE_BUILD_BUG_ON(offsetof(struct hn_stats, broadcast) !=
> > > + offsetof(struct hn_stats, multicast) +
> > sizeof(uint64_t));
> > > + if (unlikely(rte_is_multicast_ether_addr(ea)))
> > > + (&stats->multicast)[rte_is_broadcast_ether_addr(ea)]++;
> > > }
> >
> > This makes the code a little harder to read.
>
> I agree it is somewhat convoluted.
> It's a tradeoff... I preferred performance at the cost of making the code somewhat harder to read.
> The RTE_BUILD_BUG_ON() also helps showing what is going on with the weird indexing.
Optimizing for multicast packets is not worth bothering.
Keep the original code it is simpler.
More information about the dev
mailing list