DPDK usage discussions
 help / color / mirror / Atom feed
* rte_rdtsc() - what is the performance impact of using rte_rdtsc() time
@ 2023-08-29 14:55 Hari Haran
  2023-09-05 23:29 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Hari Haran @ 2023-08-29 14:55 UTC (permalink / raw)
  To: users

[-- Attachment #1: Type: text/plain, Size: 904 bytes --]

Hi All,

Subject: rte_rdtsc() - what is the performance impact of using rte_rdtsc()
time under lcore thread while(1)

Requirement:

   1. Store the packet received timestamp - based on it packets will be
   removed from buffer if it exceeds the threshold timer of buffer
   2. Two threads are available, One is lcore(dedicated core) and another
   is pthread(not a dedicated core. In pthread, have to get the timestamp of
   last received packet timestamp


Query:

   1. For every packet reception in lcore thread under while(1), will get
   the packet received timestamp using  rte_rdtsc() function. Whether usage of
   rte_rdtsc() function adds more delay in packet processing?
   2. Is there any way to convert rte_rdtsc() timestamp value to current
   system time in pthread()? In pthread, the last packet received time needed
   in the form of system time.


Thanks in advance.

Regards,
Hariharan

[-- Attachment #2: Type: text/html, Size: 2474 bytes --]

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

* Re: rte_rdtsc() - what is the performance impact of using rte_rdtsc() time
  2023-08-29 14:55 rte_rdtsc() - what is the performance impact of using rte_rdtsc() time Hari Haran
@ 2023-09-05 23:29 ` Stephen Hemminger
  2023-10-03 10:19   ` Hari Haran
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2023-09-05 23:29 UTC (permalink / raw)
  To: Hari Haran; +Cc: users

On Tue, 29 Aug 2023 20:25:54 +0530
Hari Haran <info2hariharan@gmail.com> wrote:

> Hi All,
> 
> Subject: rte_rdtsc() - what is the performance impact of using rte_rdtsc()
> time under lcore thread while(1)
> 
> Requirement:
> 
>    1. Store the packet received timestamp - based on it packets will be
>    removed from buffer if it exceeds the threshold timer of buffer
>    2. Two threads are available, One is lcore(dedicated core) and another
>    is pthread(not a dedicated core. In pthread, have to get the timestamp of
>    last received packet timestamp
> 
> 
> Query:
> 
>    1. For every packet reception in lcore thread under while(1), will get
>    the packet received timestamp using  rte_rdtsc() function. Whether usage of
>    rte_rdtsc() function adds more delay in packet processing?
>    2. Is there any way to convert rte_rdtsc() timestamp value to current
>    system time in pthread()? In pthread, the last packet received time needed
>    in the form of system time.
> 
> 
> Thanks in advance.
> 
> Regards,
> Hariharan

The problem is that rte_rdtsc() stops speculative execution so doing
lots of TSC instructions can hurt performance.

To correlate TSC timestamp to system time, you need to compute the offsets
once at startup. Alternatively, don't use rte_rdtsc() and instead use
clock_gettime() with the monotonic timer and the C library does the calculation
for you.

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

* Re: rte_rdtsc() - what is the performance impact of using rte_rdtsc() time
  2023-09-05 23:29 ` Stephen Hemminger
@ 2023-10-03 10:19   ` Hari Haran
  2023-10-03 17:17     ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Hari Haran @ 2023-10-03 10:19 UTC (permalink / raw)
  To: stephen; +Cc: users

[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]

On Wed, Sep 6, 2023 at 4:59 AM Stephen Hemminger <stephen@networkplumber.org>
wrote:

> On Tue, 29 Aug 2023 20:25:54 +0530
> Hari Haran <info2hariharan@gmail.com> wrote:
>
> > Hi All,
> >
> > Subject: rte_rdtsc() - what is the performance impact of using
> rte_rdtsc()
> > time under lcore thread while(1)
> >
> > Requirement:
> >
> >    1. Store the packet received timestamp - based on it packets will be
> >    removed from buffer if it exceeds the threshold timer of buffer
> >    2. Two threads are available, One is lcore(dedicated core) and another
> >    is pthread(not a dedicated core. In pthread, have to get the
> timestamp of
> >    last received packet timestamp
> >
> >
> > Query:
> >
> >    1. For every packet reception in lcore thread under while(1), will get
> >    the packet received timestamp using  rte_rdtsc() function. Whether
> usage of
> >    rte_rdtsc() function adds more delay in packet processing?
> >    2. Is there any way to convert rte_rdtsc() timestamp value to current
> >    system time in pthread()? In pthread, the last packet received time
> needed
> >    in the form of system time.
> >
> >
> > Thanks in advance.
> >
> > Regards,
> > Hariharan
>
> The problem is that rte_rdtsc() stops speculative execution so doing
> lots of TSC instructions can hurt performance.
>
> To correlate TSC timestamp to system time, you need to compute the offsets
> once at startup. Alternatively, don't use rte_rdtsc() and instead use
> clock_gettime() with the monotonic timer and the C library does the
> calculation
> for you.
>


As part of query 1 and based on your response, I am asking below query

But usage of clock_gettime() (kernel function) in lcore is advisable one?
My understanding is,
shall avoid usage of kernel function in lcore. Correct me if I am wrong?

TIA.

Regards,
Hariharan

[-- Attachment #2: Type: text/html, Size: 2586 bytes --]

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

* Re: rte_rdtsc() - what is the performance impact of using rte_rdtsc() time
  2023-10-03 10:19   ` Hari Haran
@ 2023-10-03 17:17     ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2023-10-03 17:17 UTC (permalink / raw)
  To: Hari Haran; +Cc: users

On Tue, 3 Oct 2023 15:49:00 +0530
Hari Haran <info2hariharan@gmail.com> wrote:

> >
> > The problem is that rte_rdtsc() stops speculative execution so doing
> > lots of TSC instructions can hurt performance.
> >
> > To correlate TSC timestamp to system time, you need to compute the offsets
> > once at startup. Alternatively, don't use rte_rdtsc() and instead use
> > clock_gettime() with the monotonic timer and the C library does the
> > calculation
> > for you.
> >  
> 
> 
> As part of query 1 and based on your response, I am asking below query
> 
> But usage of clock_gettime() (kernel function) in lcore is advisable one?
> My understanding is,
> shall avoid usage of kernel function in lcore. Correct me if I am wrong?

clock_gettime() is a virtual system call (VDSO) on most Linux platforms.
But it is still slower than simple rte_rdtsc().

Internally clock_gettime VDSO 

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

end of thread, other threads:[~2023-10-03 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29 14:55 rte_rdtsc() - what is the performance impact of using rte_rdtsc() time Hari Haran
2023-09-05 23:29 ` Stephen Hemminger
2023-10-03 10:19   ` Hari Haran
2023-10-03 17:17     ` Stephen Hemminger

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