Article View: comp.lang.c++
Article #1061Re: Consequential RCU
From: David Brown
Date: Mon, 30 Nov 2026 20:18
Date: Mon, 30 Nov 2026 20:18
108 lines
5930 bytes
5930 bytes
On 29/11/2026 22:08, Chris M. Thomasson wrote:
> On 11/29/2026 9:36 AM, Ross Finlayson wrote:
>> On 11/29/2026 12:57 AM, Chris M. Thomasson wrote:
>>> On 10/15/2026 4:26 PM, Joseph Seigh wrote:
>>>> On 10/15/26 2:49 PM, Chris M. Thomasson wrote:
>>>>> On 10/13/2026 10:01 AM, Joseph Seigh wrote:
>>>>>> On 10/11/26 11:11 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));
>>>>>
>>>>> Oh shit. This looks like it can be _potential_ "livelock" nation
>>>>> under some sustained periods of "heavy enough" load? Can we iterate
>>>>> the whole list before many (n) retrys have occurred? Or how many
>>>>> retrys on average does it take to iterate a decent sized list from
>>>>> head to tail? Writers churning along in the background...
>>>>>
>>>>
>>>> The list was used to give an idea how much overhead there would be.
>>>> I wouldn't use this for O(n) stuff where n is very large.
>>>>
>>>> In that this is similar to SEQLOCK, its docs mention the livelock
>>>> issue.
>>>> The term for these kind of algorithms is obstruction-free (Herlihy).
>>>
>>> Fwiw, speaking of SEQLOCK I think Dmitry had a nifty distributed one.
>>> Let me try to find it...
>>>
>>> https://sites.google.com/site/1024cores/home/lock-free-algorithms/
>>> reader-writer-problem/improved-lock-free-seqlock
>>>
>>>
>>>>
>>>> You could avoid this with a conventional rwlock. Probably slow you
>>>> down by orders of magnitude.
>>>>
>>>> You could use RCU since the readers are wait-free. With that many
>>>> updates deferring that much memory, you might OOM.
>>>>
>>>
>>> Yeah. I remember some old stress tests that would make malloc fail. Man
>>> that was a long time ago.
>>
>> Didn't "memory_order" get deprecated.
>
> When did that occur? Yikes!
>
> I highly doubt that c++ got rid of memory_order.
>
> Afaict, memory_order_consume got folded into memory_order_acquire. Sigh.
>
>
>> You either have opportunistic-locking about cmp-exchange |
>> load-linked+store-conditional with a datum of 64-bits about AMD
>> and aligned and padded to 64-bytes or 128 for ARM's cache-line pairs,
>> or you don't, then about that there's basically always a necessary
>> UUID-vendor to prevent ABA (i.e., "race conditions"),
>> one thing that guarantees another being the same ("unique"),
>> and another guaranteeing another being different ("unique").
>
> Well, memory_order is about ordering the visibility of operations on the
> arch. ABA has nothing to do with that. And what is that UUID-vendor that
> you mentioned? A monotonic counter works. For say a traditional lock-
> free stack, actually, ABA only needs to be incremented for a pop
> operation. For a flush op, it is not needed at all. So for a lock-free
> stack that has push/flush ABA is not a concern at all.
>
Chris, Ross' posts are just a random jumble of badly expressed ideas
that are usually unconnected with the topic being discussed, and often
completely unconnected with reality. When he started posting here, I
tried hard to understand him and help him see why many people see his
posts as incomprehensible, and not worth trying to read.
So don't worry about the things he says. A lot of it is wrong, and even
when he has got something right, he is incapable of writing about it
accurately.
No, "memory order" did not get "deprecated" (whatever that might mean in
this context). Yes, memory_order_consume is going away (because it is
very rarely used or implemented appropriately, and just makes a
difficult subject more difficult than it need be).
Technical Details
Message-ID:
<11ekln1$qb9r$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<118f4vv$3plsv$1@dont-email.me> <11ag8ue$2nvjl$1@dont-email.me> <11alo51$nmur$1@dont-email.me> <11ar78l$2m3md$1@dont-email.me> <11arng1$2rc46$1@dont-email.me> <11egpem$3bdhn$1@dont-email.me> <97udnVnjLs4V_5H2nZ2dnZfqnPudnZ2d@giganews.com> <11ei485$3s1u1$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c++ Subject: Re: Consequential RCU Date: Mon, 30 Nov 2026 21:18:41 +0100 Organization: A noiseless patient Spider Lines: 108 Message-ID: <11ekln1$qb9r$1@dont-email.me> References: <118f4vv$3plsv$1@dont-email.me> <11ag8ue$2nvjl$1@dont-email.me> <11alo51$nmur$1@dont-email.me> <11ar78l$2m3md$1@dont-email.me> <11arng1$2rc46$1@dont-email.me> <11egpem$3bdhn$1@dont-email.me> <97udnVnjLs4V_5H2nZ2dnZfqnPudnZ2d@giganews.com> <11ei485$3s1u1$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 30 Nov 2026 20:18:42 +0000 (UTC) Injection-Info: dont-email.me; logging-data="863547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19q8TTISLbaCfqbrPmCOO7Hb+UcEVbFMgg="; posting-host="a448ec79be8238d2c3ca54b79fa3e2af" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:PS95DRqKeICmcScHj2nomlErQVI= sha256:zT4aX4j3V4SisJaNq7DGQX1sLajKeMUH3I6p5ejAlhA= sha1:Rd0bMMCb/1L2u0A+JvnBA06kJBU= sha256:wU6dl+ScYUV0LIH1yz/K7avvTZIZqaC16dscZfU6W9c= In-Reply-To: <11ei485$3s1u1$1@dont-email.me> Content-Language: en-GB