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 CAE1342D71; Tue, 27 Jun 2023 12:41:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE75540F18; Tue, 27 Jun 2023 12:41:31 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 2B41540EE1 for ; Tue, 27 Jun 2023 12:41:30 +0200 (CEST) Received: from frapeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Qr1Qp6ft8z6D92W; Tue, 27 Jun 2023 18:38:42 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml500005.china.huawei.com (7.182.85.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 12:41:29 +0200 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.027; Tue, 27 Jun 2023 12:41:29 +0200 From: Konstantin Ananyev To: =?iso-8859-1?Q?Morten_Br=F8rup?= , "honnappa.nagarahalli@arm.com" , "bruce.richardson@intel.com" , Gavin Hu CC: "dev@dpdk.org" Subject: RE: Ring algorithm with fewer cache misses Thread-Topic: Ring algorithm with fewer cache misses Thread-Index: Admo2r6QgkGTXKoMSUGgWVDDp5xAfAAB8RyQ Date: Tue, 27 Jun 2023 10:41:29 +0000 Message-ID: References: <98CBD80474FA8B44BF855DF32C47DC35D87A1C@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87A1C@smartserver.smartshare.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.48.158.13] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected 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 Morten, =20 > Hi Honnappa, Konstantin, Bruce and Gavin, >=20 > You might find this ring algorithm optimization article interesting: > https://rigtorp.se/ringbuffer/ >=20 >=20 > It adds the following optimization: >=20 > 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). >=20 > 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. >=20 >=20 > Similarly, the single-consumer get() operation caches the producer's inde= x to determine if there were still sufficient objects present in > the ring after the previous get() operation. >=20 Indeed, that sounds like an interesting idea and worth to explore. Thinking a bit more - it probably could be extended to classic MP/MC case t= oo - If we can update cons/prod head and this cached value atomically (CAS64?). Thanks Konstantin