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


Hi Morten,
 
> 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.
> 

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 too -
If we can update cons/prod head and this cached value atomically (CAS64?).
Thanks
Konstantin

      reply	other threads:[~2023-06-27 10:41 UTC|newest]

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

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