From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59E0742D70; Tue, 27 Jun 2023 11:35:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D937E4113F; Tue, 27 Jun 2023 11:35:46 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 4370040F18 for ; Tue, 27 Jun 2023 11:35:45 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 160D020644; Tue, 27 Jun 2023 11:35:45 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Ring algorithm with fewer cache misses Date: Tue, 27 Jun 2023 11:35:43 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87A1C@smartserver.smartshare.dk> X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Ring algorithm with fewer cache misses Thread-Index: Admo2r6QgkGTXKoMSUGgWVDDp5xAfA== From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: , , , "Gavin Hu" Cc: X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Honnappa, Konstantin, Bruce and Gavin, You might find this ring algorithm optimization article interesting: https://rigtorp.se/ringbuffer/ It adds the following optimization: The single-producer put() operation keeps a cache of the consumer's = index. If the cached consumer index indicates that there was still = sufficient room in the ring after the previous put() operation, it = doesn't need to fetch the actual consumer index, and thus avoids a = potential L1 cache miss (because the actual consumer index is written by = the consumer threads). If the cached index doesn't indicate that there is sufficient room in = the ring, the operation behaves like without the optimization, i.e. it = proceeds to fetch the actual consumer index (and writes it to its cache) = and determines if there is sufficient room in the ring. Similarly, the single-consumer get() operation caches the producer's = index to determine if there were still sufficient objects present in the = ring after the previous get() operation. Med venlig hilsen / Kind regards, -Morten Br=F8rup