Article View: comp.lang.c++
Article #211Re: Consequential RCU
From: Chris M. Thomasson
Date: Mon, 12 Oct 2026 03:04
Date: Mon, 12 Oct 2026 03:04
114 lines
5238 bytes
5238 bytes
On 10/11/2026 6:44 PM, Joseph Seigh wrote:
> On 10/11/26 5:10 PM, Chris M. Thomasson wrote:
>
>>
>> If you get some free time to burn, add my proxy to your test bench.
>> Its simply not meant to beat fancy asymmetric RCU+SMR type algos, but
>> it works in 100% std C++. Which is fairly decent.
>>
>> https://pastebin.com/raw/CYZ78gVj
>>
>> It should just compile right up and run.
>
> SMRProxy read lock is just an atomic load and store w/o membar.
> I did a quick and dirty perf test of what would be the typical
> user space RCU read lock logic, incrementing a local counter.
I don't have any of my old tests anymore from 2003-2010 ish. Damn. It
was fun to compare and contrast different proxys back in the day. My
collector is always going to lose against a proper RCU, or SMRProxy,
RCU-SMR hybrid. But, iirc, they can be useful for the writer side of the
algo. Also, its fun to see them beat a read/write lock. Some of those
tests where pretty lop sided where I had to terminate the read-write
lock version because it was taking way too long. Remember when you first
came up with the proxy using your atomic_ptr way back on c.p.t?
Fwiw, I think your old tests measured reads per-thread per-second?
> An atomic load, increment of loaded value, and atomic store
> of that value is basically just as fast as SMRProxy, despite
> that increment. An atomic increment is quite a bit slower
> on x86 since you have a full memory barrier there. You
> can't use asymmetric memory barriers to avoid that in this
> case.
Well, if your "crafty" there is a way to "amortize" it... But it
involves a certain usage pattern. A user needs to be familiar with it so
it tends to be a hard sell. Anyway, basically in my proxy, or any proxy,
I think.
try_to_iterate just tries to iterate a linked structure or something. If
its empty it returns false. Otherwise, true:
_______________
collector& c = proxy_acquire();
for (unsigned long i = 1 ;; ++i)
{
if (! try_to_iterate(c, shared_lock_free_list))
{
break;
}
if (! (i % 4096))
{
c = proxy_sync(c);
}
}
proxy_release(c);
_______________
basically, proxy_sync is the following function in my old code:
_______________
collector& sync(collector& c)
{
// check if the `c' is in the middle of a quiescence process.
if (c.m_count.load(std::memory_order_relaxed) & ct_proxy_quiescent)
{
// drop `c' and get the next collector.
release(c);
return acquire();
}
return c;
}
_______________
So, it actually works way better when its under load! Funny.
> QSBR and EBR are basically the same thing. Grace periods are
> epochs. The only difference is the QSBR logic to decide what
> grace period each reader is referencing is a bit more indirect.
> You are looking at events rather than conditions. I didn't
> do a user space RCU implementation since I didn't want to
> deal with that extra logic. And there are enough user space
> RCU implementations out there already.
Yeah. I just always liked my single word proxy. Its nice that its 100%
portable wrt std C++. I remember your first one using atomic_ptr. Iirc,
it had the backlink and called dtors recursively. Fwiw, mine old proxy
just calls:
_______________
static std::uint32_t prv_destroy(ct_node* n)
{
std::uint32_t count = 0;
while (n)
{
ct_node* next = n->m_defer_next;
delete n;
count++;
n = next;
}
return count;
}
_______________
Sometimes I feel like getting back into these. Too busy with vector
fields and fractals now. Having a lot of fun with compute and frag
shaders, etc...
Technical Details
Message-ID:
<11ahinh$37ab7$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> <11agu01$30u71$1@dont-email.me> <11ahe1d$35ol8$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: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: comp.lang.c++ Subject: Re: Consequential RCU Date: Sun, 11 Oct 2026 20:04:12 -0700 Organization: A noiseless patient Spider Lines: 114 Message-ID: <11ahinh$37ab7$1@dont-email.me> References: <118f4vv$3plsv$1@dont-email.me> <11ag8ue$2nvjl$1@dont-email.me> <11agu01$30u71$1@dont-email.me> <11ahe1d$35ol8$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 12 Oct 2026 03:04:18 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3385703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+h0kF4a1P8O6KscqEJoLUErE41C2iVHiU="; posting-host="23695f1b3419bf2835ebd55b3868dbf0" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:zDimgo1r6D/4sZ9OWGHA8+8yl4k= sha256:+8ZYFQq2w/a1z2ecqXS0JbPfw10ALY+jlh3ZQfdPFbg= sha1:RYbOSDuq5wiRFBhD/la35r028l8= sha256:QG6v9mOifc3DKSTFzR+uYzhMrSS703u+Irb9HwtErXo= Content-Language: en-US In-Reply-To: <11ahe1d$35ol8$1@dont-email.me>