DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier MATZ <olivier.matz@6wind.com>
To: "dev@dpdk.org" <dev@dpdk.org>, Remy Horton <remy.horton@intel.com>
Subject: [dpdk-dev] xstats performance
Date: Wed, 29 Jun 2016 17:38:33 +0200	[thread overview]
Message-ID: <5773EB79.1090509@6wind.com> (raw)

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

             reply	other threads:[~2016-06-29 15:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 15:38 Olivier MATZ [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5773EB79.1090509@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=remy.horton@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).