DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] xstats performance
@ 2016-06-29 15:38 Olivier MATZ
  2016-06-29 16:03 ` Remy Horton
  0 siblings, 1 reply; 8+ messages in thread
From: Olivier MATZ @ 2016-06-29 15:38 UTC (permalink / raw)
  To: dev, Remy Horton

Hi Remy,

While adapting an application to the new xstats API, I discovered
that it may not be so efficient to display the statistics and their
names.

I think the test-pmd code illustrates the issue pretty well:

/* Display xstats */
for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++)
	for (idx_name = 0; idx_name < cnt_xstats; idx_name++)
		if (xstats_names[idx_name].id == xstats[idx_xstat].id) {
			printf("%s: %"PRIu64"\n",
				xstats_names[idx_name].name,
				xstats[idx_xstat].value);
			break;
		}

The displaying is in O(n^2).

It's possible to enhance the code to have it in O(n), but it
requires an intermediate table.

Why not changing this:

   struct rte_eth_xstat {
   	uint64_t id;
   	uint64_t value;
   };
   struct rte_eth_xstat_name {
   	char name[RTE_ETH_XSTATS_NAME_SIZE];
   	uint64_t id;
   };

Into this:

   struct rte_eth_xstat {
   	uint64_t id;
   	uint64_t value;
   };
   struct rte_eth_xstat_name {
   	char name[RTE_ETH_XSTATS_NAME_SIZE];
   	/* No identifier */
   };

And assume that the id field in rte_eth_xstat corresponds to
the index in the rte_eth_xstat_name table?


The test-pmd code would be something like this:

/* Display xstats */
for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) {
	printf("%s: %"PRIu64"\n",
		xstats_names[xstats[idx_xstats].id].name,
		xstats[idx_xstat].value);
}


What do you think?

Regards
Olivier

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

end of thread, other threads:[~2016-07-08 11:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 15:38 [dpdk-dev] xstats performance Olivier MATZ
2016-06-29 16:03 ` Remy Horton
2016-06-29 16:40   ` Thomas Monjalon
2016-07-01  9:15     ` Remy Horton
2016-07-05 18:10       ` Rasesh Mody
2016-07-06  7:43         ` Remy Horton
2016-07-07 22:59           ` Rasesh Mody
2016-07-08 11:15             ` Remy Horton

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).