Article View: comp.lang.c++
Article #574Re: Consequential RCU
From: Joseph Seigh
Date: Thu, 15 Oct 2026 23:26
Date: Thu, 15 Oct 2026 23:26
51 lines
3151 bytes
3151 bytes
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).
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.
Technical Details
Message-ID:
<11arng1$2rc46$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-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>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: Joseph Seigh <jseigh_es00@xemaps.com> Newsgroups: comp.lang.c++ Subject: Re: Consequential RCU Date: Thu, 15 Oct 2026 19:26:57 -0400 Organization: A noiseless patient Spider Lines: 51 Message-ID: <11arng1$2rc46$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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 15 Oct 2026 23:26:57 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2994310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WmMPxBqi2fNxb4Jm4JTgJ"; posting-host="441e0c3773a2c3eebc41686a51dfb9d7" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:HQb5p1r5ZkuRkGinBpszJKiagJc= sha256:fDfalUuHkzOfzMGI5DAcQ6mUAer5ZSKEiEYyJvTimnw= sha1:hwwLiAmfvYzKQxeKamLL1urMeik= sha256:17m+nyYN2D1wP4ZqlS8zcYAzrGabysuISMZjQ3FKYmg= Content-Language: en-US In-Reply-To: <11ar78l$2m3md$1@dont-email.me>