DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: <honnappa.nagarahalli@arm.com>, <konstantin.ananyev@huawei.com>,
	<bruce.richardson@intel.com>, "Gavin Hu" <gavin.hu@arm.com>
Cc: <dev@dpdk.org>
Subject: Ring algorithm with fewer cache misses
Date: Tue, 27 Jun 2023 11:35:43 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87A1C@smartserver.smartshare.dk> (raw)

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ørup



             reply	other threads:[~2023-06-27  9:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27  9:35 Morten Brørup [this message]
2023-06-27 10:41 ` Konstantin Ananyev

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=98CBD80474FA8B44BF855DF32C47DC35D87A1C@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=gavin.hu@arm.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=konstantin.ananyev@huawei.com \
    /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).