Article View: comp.lang.c++
Article #1050Re: Consequential RCU
From: Chris M. Thomasson
Date: Sun, 29 Nov 2026 08:57
Date: Sun, 29 Nov 2026 08:57
61 lines
3579 bytes
3579 bytes
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.
Technical Details
Message-ID:
<11egpem$3bdhn$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>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: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: comp.lang.c++ Subject: Re: Consequential RCU Date: Sun, 29 Nov 2026 00:57:55 -0800 Organization: A noiseless patient Spider Lines: 61 Message-ID: <11egpem$3bdhn$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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 29 Nov 2026 08:57:58 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3520055"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fZtdbFKi3+chQ7tdAibNCZfwp4lX0sPk="; posting-host="154a170364bb3f201858dda21f806e24" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:n3xmQTc97ws5gMINH3QCPI9AGrk= sha256:KfJph+q12W6ZAYfvIPks7/RCWFhuHH4HugoAES2nGAE= sha1:ZbcwvCDsBvr2mpOyCsovgLFLBec= sha256:R5gkzptgKH4X43LIGIBpXQ8hFA6ooBD/kSexZygNxSw= In-Reply-To: <11arng1$2rc46$1@dont-email.me> Content-Language: en-US