Article View: comp.lang.c++
Article #1058Re: Consequential RCU
From: Ross Finlayson
Date: Mon, 30 Nov 2026 09:05
Date: Mon, 30 Nov 2026 09:05
151 lines
8366 bytes
8366 bytes
On 11/29/2026 01:08 PM, 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.
>
I think "memory_order considered deprecated" is because what would
support that, or "mfence", is hardware and the model of invention has
that the only atomic memory hardware primitive is compare-and-swap,
which is load-linked/store-conditional on ARM though ARM is also
adding or added compare-and-swap, LL/SC because the value to be checked
should usually be checked immediately under contention to reduce the
window of ABA (i.e., TA checks A, TB checksA/writes B, TC checks
B/writes A, TA writes A, -> TA duplicated TC, race-condition TA
duplicated TC). Then, "counters" either may collide or be atomic, about
then that for "no-drops/no-dupes" that to get an atomic now requires two
of them. If the instruction-set-architecture had an instruction that
guaranteeed a system-wide counter, or basically the core ID, I suppose
the core ID would suffice for the UUID part, which though would be
volatile in the abstract, if threads ever migrated.
The UUID-vendor is the usual idea that in a distributed-system there's
a bottleneck to critical-transactionality that unique messages, for
no-drops/no-dupes, need each a unique ID, to be otherwise
"horizontally-independent" thus "horizontally-scale-able", then for
example about "forward-safe state-machines", since that in the case of
other components not being "drop/dupe-safe", like message queues of the
usual distributed variety that usually guarantee "no drops" (for
submissions that make it successfully to the queue) yet don't guarantee
"no dupes", about idempotency and so on that then the state of the
machine of the "model of asynchronous, distributed operation" is
well-defined. This is that a "forward-safe state-machine" is a usual
key sort of fundamental concept itself, that besides tagging an atomic
with the actor-ID, and workflow-ID, then that the states are only valid
A -> B -> C, and that whatever makes A -> B and B -> C are "idempotent",
here meaning side-effect free and returning same results for same
inputs. I.e. that there's an ID table (critically transactional to vend
the UUID) and a data table (not critically transactional throughout the
life of the workflow, updating the row idempotently).
The "no-drops" is a usual idea for vending _serial_ IDs, for detecting
gaps, then "no-dupes" is a usual common error-mode in
distributed-systems that rely on message-queues and so on.
So, "horizontally-scaleable self-healing distributed workflow-item
processing-systems with no-drops/no-dupes" involve this kind of thing,
for example "models of asynchronous operation that aren't idempotent
and thus need assurance of no-drops/no-dupes".
I haven't seen the worst code in the world when it comes to
"message-queues and the message-bus", yet, usually it's
not so great, and there's either a UUID that's also serial,
or there are dupes (duplicates).
"Matching & Reconciliation" is a usual sort of idea,
which though can be reduced problems with "no ABA dupes".
Technical Details
Message-ID:
<65qdnRhb7cvNoZD2nZ2dnZfqn_WdnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.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!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 30 Nov 2026 09:05:20 +0000 Subject: Re: Consequential RCU Newsgroups: comp.lang.c++ 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> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Mon, 30 Nov 2026 01:05:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <11ei485$3s1u1$1@dont-email.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <65qdnRhb7cvNoZD2nZ2dnZfqn_WdnZ2d@giganews.com> Lines: 151 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-UIvTDr0+9AHeRL3NRg0/4+NjSRxvqYDtkGFl7tof0WNNhuXX38YEMKlfwPFJXfQ/ig5qTDEz1g/HPC2!Vb3Vw7ATgWHJ2aglQXDP2DrUlSkIXGSz/PJNiY0YCact7PLdGZk8h6fP7BKeaZf9GVwiiA84BPVt X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Received-Bytes: 8141