From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <users-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 3724942503
	for <public@inbox.dpdk.org>; Wed,  6 Sep 2023 01:29:34 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B360940DDE;
	Wed,  6 Sep 2023 01:29:33 +0200 (CEST)
Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com
 [209.85.214.174])
 by mails.dpdk.org (Postfix) with ESMTP id 115E6406B7
 for <users@dpdk.org>; Wed,  6 Sep 2023 01:29:32 +0200 (CEST)
Received: by mail-pl1-f174.google.com with SMTP id
 d9443c01a7336-1c1ff5b741cso24069075ad.2
 for <users@dpdk.org>; Tue, 05 Sep 2023 16:29:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1693956571;
 x=1694561371; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:from:to:cc:subject:date
 :message-id:reply-to;
 bh=ZjuhQAvbPM27kSjswCd+9m0xh+dMqVzLXDV2QBoVLZc=;
 b=FedEnwe0PgfaIu9EhHXXNVISyTz0WEXOX0VEAJzAV6xWdvdIHjiww+q93b6I7bYm7m
 NWLeGeXDWfZU6a9VcYcP+hr7wE/mpwramGYljLl3FWvRUeT4CVV8AeyvIDcpHAimjeqp
 5ZwQQBH13MLeUUltRwW1hM7Lb3G1U/dzXLz8g+Bwoy54nYBzxjpf6esQVG1doQ91Ou5Z
 EK3OJNzy9hadoSergKjHsPiEPeeA4Ksujikm75OGxoBFK/bXKldi8ejfMoZpB6bSwH5d
 Yh+9T0qPFhgE5URfairnScsG2Lw8YIBrzTCwjfWzfaozjxKvepOl5OR0btz47yCf3nAi
 b8OA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693956571; x=1694561371;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=ZjuhQAvbPM27kSjswCd+9m0xh+dMqVzLXDV2QBoVLZc=;
 b=cUya44I8+zYDGYvNGTqiy96w2wMlb7iaOVwtmYZKH2QOsqUW/l3JMxOJK4P5Xh1Abe
 eACQn+hi2umgsT2bjiEx4wpEnjWOpvDhSJ9LHG74mizaJzptQmV2wavvv0zCMRUjdjq0
 bl8wDE6wQZ2KxuV581uUViRQ2kkSuBTENZrtdBsxDvtsp5djbJ9FYDg2joso5PI4Egxf
 KSnDfSRFloFaUwU5uu6XegiuWWO/1+i5qQdRGjfFLOl/Vxn1HJz482xIDb5/ba+CcAgM
 EJ67XUGk04yTvavbZEAza7YghFB2pz55V/9Yc6q8CGRUBJeqhVIzL7zSzwl/JS3TPson
 qt+g==
X-Gm-Message-State: AOJu0YzsRTNjFhpb4dRbwdGFe7+lpDQvPzUVD2lbnbsYrfDTQ94l/ZH4
 seiM/EqyFaG8UmhR48ow7PTmeg==
X-Google-Smtp-Source: AGHT+IHxLuJROvgFl53OgPmkaSZaapeyjAQudDfsE8XVODecZKFmdDPbw47A2Hk3Q1AKRLm9jJg0Gg==
X-Received: by 2002:a17:902:be05:b0:1bd:d6b5:a54f with SMTP id
 r5-20020a170902be0500b001bdd6b5a54fmr13917570pls.55.1693956570892; 
 Tue, 05 Sep 2023 16:29:30 -0700 (PDT)
Received: from hermes.local (204-195-112-131.wavecable.com. [204.195.112.131])
 by smtp.gmail.com with ESMTPSA id
 t23-20020a1709028c9700b001bb515e6b39sm9775154plo.306.2023.09.05.16.29.30
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 05 Sep 2023 16:29:30 -0700 (PDT)
Date: Tue, 5 Sep 2023 16:29:29 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Hari Haran <info2hariharan@gmail.com>
Cc: users@dpdk.org
Subject: Re: rte_rdtsc() - what is the performance impact of using
 rte_rdtsc() time
Message-ID: <20230905162929.3dbc9e12@hermes.local>
In-Reply-To: <CAPbxCtrRqXHU772U7eZFoDcKL2pRiE39vgBifWYC96kC04MhiQ@mail.gmail.com>
References: <CAPbxCtrRqXHU772U7eZFoDcKL2pRiE39vgBifWYC96kC04MhiQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: users@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK usage discussions <users.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/users>,
 <mailto:users-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/users/>
List-Post: <mailto:users@dpdk.org>
List-Help: <mailto:users-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/users>,
 <mailto:users-request@dpdk.org?subject=subscribe>
Errors-To: users-bounces@dpdk.org

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.