🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #556

Re: Consequential RCU

#556
From: Chris M. Thomasson
Date: Wed, 14 Oct 2026 21:46
86 lines
4077 bytes
On 10/14/2026 2:16 PM, Chris M. Thomasson wrote:
> On 10/13/2026 4:34 PM, Joseph Seigh wrote:
>> On 10/13/26 3:36 PM, Chris M. Thomasson wrote:
>>> On 10/13/2026 10:01 AM, Joseph Seigh wrote:
>>
>>>> This is what the code I did a quick and dirty test with looked like
>>>>
>>>> using csequence_t = uint64_t;
>>>>
>>>> inline bool cseq_retry(csequence_t mark, std::atomic<csequence_t> & 
>>>> sequence)
>>>> {
>>>>      std::atomic_thread_fence(std::memory_order_acquire);
>>>>      return mark != sequence.load(std::memory_order_acquire);
>>>> }
>>>>
>>>> csequence_t mark;
>>>>
>>>> retry:
>>>> do {
>>>>
>>>>      mark = cseq_count.load(std::memory_order_acquire);
>>>>      node_t * item = list.load(std::memory_order_acquire);
>>>>
>>>>      for (int ndx2 = 0; ndx2 < depth; ndx2++) {
>>>>          item = item->next.load(std::memory_order_acquire);
>>>>          if (cseq_retry(mark, cseq_count)) [[unlikely]]
>>>>              goto retry;
>>>>      }
>>>>
>>>> } while (cseq_retry(mark, cseq_count));
>>>>
>>>>
>>>> As you can see, not a heck of lot of room in that loop
>>>> for the cpu pipeline to deal with the extra load and
>>>> conditional logic.
> [...]
> 
> Its interesting. Btw, I don't even need traditional SMR logic! This 
> works fine:
> ________________
> per_node*
> smr_load(
>      unsigned long tidx
> ) {
>      per_node* node0 = m_node.load(rl::mo_relaxed, $);
>      m_threads[tidx].m_haz_0.store(node0, rl::mo_relaxed, $);
>      return node0;
> }
> ________________
Oh OUCH! Sorry Joe. This does not work in Relacy. I forgot to run that 
test in my ct_main.cpp launcher. So, god damn it. I still need a consume 
barrier, or I think C++ fold that into acquire right?

  per_node*
  smr_load(
      unsigned long tidx
  ) {
      for (;;)
      {
          per_node* node0 = m_node.load(rl::mo_relaxed, $);

          if (! node0)
          {
              RL_ASSERT(0); // hould never happen in this test!
              m_threads[tidx].m_haz_0.store(nullptr, rl::mo_relaxed, $);
              break;
          }

          m_threads[tidx].m_haz_0.store(node0, rl::mo_relaxed, $);

          // actually, iirc, a single seq_cst right here should work?
          // well, this is an async test...

          per_node* node1 = m_node.load(rl::mo_consume, $);

          // uncomment below, Relacy goes berserker!
          //per_node* node1 = m_node.load(rl::mo_relaxed, $);
          if (node0 == node1)
          {
              return node0;
          }
      }

      return nullptr;
  }
Technical Details
Message-ID: <11aot8a$1sgao$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <118f4vv$3plsv$1@dont-email.me> <11ag8ue$2nvjl$1@dont-email.me> <11alo51$nmur$1@dont-email.me> <11am17q$rl8q$1@dont-email.me> <11amf6v$10g9m$1@dont-email.me> <11aorf3$1rrdk$2@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: Consequential RCU
Date: Wed, 14 Oct 2026 14:46:49 -0700
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <11aot8a$1sgao$1@dont-email.me>
References: <118f4vv$3plsv$1@dont-email.me> <11ag8ue$2nvjl$1@dont-email.me>
 <11alo51$nmur$1@dont-email.me> <11am17q$rl8q$1@dont-email.me>
 <11amf6v$10g9m$1@dont-email.me> <11aorf3$1rrdk$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 14 Oct 2026 21:46:51 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1982808"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/uIGO6oOZkAwJI9WU6pStMVv5970gZnPQ="; posting-host="643801f06158b8bfbdcc975916b62ee0"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:AK6cWZCS5NssxNzUYaig9OWx9ac= sha256:Y/gh38+BLxheegMgvQrjWqGHE+3EMyEZk70TEPZV0Ko=
	sha1:Gdw6QdzjYC/UiI4HUybmkVuCI9Q= sha256:daNdakVlXso5Zkxj48VyejiBIu65rVmu3udatplWQ/s=
Content-Language: en-US
In-Reply-To: <11aorf3$1rrdk$2@dont-email.me>