DPDK patches and discussions
 help / color / mirror / Atom feed
* rte_eth_stats_get seems slow
@ 2025-04-25 11:52 Morten Brørup
  2025-04-26 15:23 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Morten Brørup @ 2025-04-25 11:52 UTC (permalink / raw)
  To: bruce.richardson; +Cc: Ian Stokes, dev

Bruce,

rte_eth_stats_get() on Intel NICs seems slow to me.

E.g. getting the stats on a single port takes ~132 us (~451,000 CPU cycles) using the igb driver, and ~50 us using the i40e driver.

Referring to the igb driver source code [1], it's 44 calls to E1000_READ_REG(), so the math says that each one takes 3 us (~10,000 CPU cycles).

Is this expected behavior?

It adds up, e.g. it takes a full millisecond to fetch the stats from eight ports using the igb driver.

[1]: https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/e1000/igb_ethdev.c#L1724


Med venlig hilsen / Kind regards,
-Morten Brørup


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rte_eth_stats_get seems slow
  2025-04-25 11:52 rte_eth_stats_get seems slow Morten Brørup
@ 2025-04-26 15:23 ` Stephen Hemminger
  2025-04-27  7:00   ` Morten Brørup
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2025-04-26 15:23 UTC (permalink / raw)
  To: Morten Brørup; +Cc: bruce.richardson, Ian Stokes, dev

On Fri, 25 Apr 2025 13:52:55 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:

> Bruce,
> 
> rte_eth_stats_get() on Intel NICs seems slow to me.
> 
> E.g. getting the stats on a single port takes ~132 us (~451,000 CPU cycles) using the igb driver, and ~50 us using the i40e driver.
> 
> Referring to the igb driver source code [1], it's 44 calls to E1000_READ_REG(), so the math says that each one takes 3 us (~10,000 CPU cycles).
> 
> Is this expected behavior?
> 
> It adds up, e.g. it takes a full millisecond to fetch the stats from eight ports using the igb driver.
> 
> [1]: https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/e1000/igb_ethdev.c#L1724
> 
> 
> Med venlig hilsen / Kind regards,
> -Morten Brørup
> 

Well reading each stat requires a PCI access. And PCI accesses are non-cached.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: rte_eth_stats_get seems slow
  2025-04-26 15:23 ` Stephen Hemminger
@ 2025-04-27  7:00   ` Morten Brørup
  0 siblings, 0 replies; 3+ messages in thread
From: Morten Brørup @ 2025-04-27  7:00 UTC (permalink / raw)
  To: Stephen Hemminger, bruce.richardson; +Cc: dev

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, 26 April 2025 17.24
> 
> On Fri, 25 Apr 2025 13:52:55 +0200
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > Bruce,
> >
> > rte_eth_stats_get() on Intel NICs seems slow to me.
> >
> > E.g. getting the stats on a single port takes ~132 us (~451,000 CPU
> cycles) using the igb driver, and ~50 us using the i40e driver.
> >
> > Referring to the igb driver source code [1], it's 44 calls to
> E1000_READ_REG(), so the math says that each one takes 3 us (~10,000
> CPU cycles).
> >
> > Is this expected behavior?
> >
> > It adds up, e.g. it takes a full millisecond to fetch the stats from
> eight ports using the igb driver.
> >
> > [1]:
> https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/net/e1000/igb_e
> thdev.c#L1724
> >
> >
> > Med venlig hilsen / Kind regards,
> > -Morten Brørup
> >
> 
> Well reading each stat requires a PCI access. And PCI accesses are non-
> cached.

You're right, thank you for reminding me. I was caught by surprise that getting 7 counters took so long.
Perhaps reading 44 NIC registers over the PCI bus is required to calculate those summary counters. Or nobody cared to optimize this function to only read the necessary registers.

We periodically poll the ethdev stats in a management thread, and I noticed the duration because of the jitter it caused in that thread.
It's not a real problem. If it was, we could easily move it to a separate thread or poll the counters iteratively port by port, instead of all ports in one go.
A longwinded way of saying: Probably not worth optimizing. ;-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-27  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-25 11:52 rte_eth_stats_get seems slow Morten Brørup
2025-04-26 15:23 ` Stephen Hemminger
2025-04-27  7:00   ` Morten Brørup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).