DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ravi Kumar Iyer <Ravi.Iyer@aricent.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] cost of reading tsc register
Date: Mon, 20 Apr 2015 14:37:53 +0000	[thread overview]
Message-ID: <115e8a38d223487488d22a99f53cc926@GURMBXV03.AD.ARICENT.COM> (raw)

Hi,
We were doing some code optimizations , running DPDK based applications, and chanced upon the rte_rdtsc function [ to read tsc timestamp register value ] consuming cpu cycles of the order of 100clock cycles with a delta of upto 40cycles at times [ 60-140 cycles]

We are actually building up a cpu intensive application which is also very clock cycle sensitive and this is impacting our implementation.

To validate the same using a small/vanilla application we wrote a small code and tested on a single core.
Has anyone else faced a similar issue or are we doing something really atrocious here.

Below is the pseudo snip of the same:


<snip start>
uint64_t g_tsc_cost[8] __rte_cache_aligned;

void test_tsc_cost()
{
    uint8_t i = 0;
    for (i = 0; i < 8 ; i++)
    {
        g_tsc_cost[i] = rte_rdtsc();
      }
}
int
main(int argc, char **argv)
{

    int ret;
    unsigned lcore_id;

    ret = rte_eal_init(argc, argv);
    if (ret < 0)
        rte_panic("Cannot init EAL\n");

    memset(g_tsc_cost,0,64); /* warm the cache */

    uint64_t sc = rte_rdtsc(); /* start count */
    test_tsc_cost();
    uint64_t ec = rte_rdtsc(); /* end count */

    printf("\n Total cost = %lu\n",(ec-sc));

    uint8_t i = 0;

    for (i = 0; i < 8 ; i++)
    {
        printf("\n g_tsc_cost[%d]=%lu",i,g_tsc_cost[i]);
       /* here the values printed are 60-140 units apart */

    }
    return 0;
}
<snip end>

Just to compare, On few bare metal implementations of non-intel processors, we are seeing the similar code print values with a delta of 3-4 cycles and thus its becoming a bit difficult to digest as well.  Grateful for any help/guidance here.

Thanks
ravi




"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."

             reply	other threads:[~2015-04-20 14:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 14:37 Ravi Kumar Iyer [this message]
2015-04-20 15:37 ` Stephen Hemminger
2015-04-20 16:21 ` Matthew Hall
2015-04-22  7:53 ` Pawel Wodkowski

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=115e8a38d223487488d22a99f53cc926@GURMBXV03.AD.ARICENT.COM \
    --to=ravi.iyer@aricent.com \
    --cc=dev@dpdk.org \
    /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).