Saturday, December 9, 2023

Digest for comp.lang.c++@googlegroups.com - 8 updates in 3 topics

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 08:48PM -0800

On 12/7/2023 5:28 PM, Chris M. Thomasson wrote:
 
>> Some timing comparisons in my blog here
>> https://threadnought.wordpress.com/2023/06/09/smrproxy-timing-comparisons/
> [...]
 
Ahhh, I just found some time to look at your work. Fun times ahead!
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 08:51PM -0800

On 12/8/2023 8:48 PM, Chris M. Thomasson wrote:
> On 12/7/2023 5:28 PM, Chris M. Thomasson wrote:
>> On 12/7/2023 2:52 PM, jseigh wrote:
[...]
>>> https://threadnought.wordpress.com/2023/06/09/smrproxy-timing-comparisons/
>> [...]
 
> Ahhh, I just found some time to look at your work. Fun times ahead!
 
Ahhh, I am being reminded of differential reference counting. :^)
Bonita Montero <Bonita.Montero@gmail.com>: Dec 09 07:11PM +0100

Am 08.12.2023 um 21:17 schrieb Chris M. Thomasson:
 
> Humm.. Oh really? Fwiw, RCU and SMR (aka, Hazard pointers) are different
> things. Userland RCU is not hazard pointers, and vise versa.
 
Ok, but there's usually still no significant gain over
a atomic<<>shared_ptr>> outside synthetic benchmarks.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 09 12:54PM -0800

On 12/9/2023 10:11 AM, Bonita Montero wrote:
>> different things. Userland RCU is not hazard pointers, and vise versa.
 
> Ok, but there's usually still no significant gain over
> a atomic<<>shared_ptr>> outside synthetic benchmarks.
 
If you say so. :^)
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 06:41PM -0800

On 12/8/2023 2:41 PM, Kaz Kylheku wrote:
>> gains features you don't want?
 
> If you don't learn those features, you no longer know C++. You're a
> C++17 has-been.
 
Humm... Depends on your team and what the requirements are, in a sense?
Humm...
David Brown <david.brown@hesbynett.no>: Dec 09 03:22PM +0100

On 08/12/2023 23:41, Kaz Kylheku wrote:
>> gains features you don't want?
 
> If you don't learn those features, you no longer know C++. You're a
> C++17 has-been.
 
I'm sorry, I can't relate to that. That is simply not how real-world
development is done, in my area at least (small-systems embedded
programming). But if you think that knowing and using all the latest
features of the latest standards is a requirement to stay "relevant" as
a C++ developer, then I can understand why you feel frustrated.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 10:27PM -0800

Food for thought. We can atomically increment a reference count along
with obtaining a reference to an object in a single fetch-and-add. All
in pure C++11
 
Say we have some objects:
 
collectors[CN];
 
 
And a reference count, say, 32 bit words:
 
RC = 0xRRRRRRCC
 
Where R is reference count space, and C is an index into collectors...
 
So, to obtain a reference we can simply:
 
word = fetch_and_add(&RC, 0x100);
 
Now we have incremented the count and obtained an index into the
collectors in one shot without DWCAS. ;^)
 
I cannot remember if this trick for single word proxy collectors is
patented!
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 10:36PM -0800

On 12/8/2023 10:27 PM, Chris M. Thomasson wrote:
 
> Where R is reference count space, and C is an index into collectors...
 
> So, to obtain a reference we can simply:
 
> word = fetch_and_add(&RC, 0x100);
 
Fwiw, another trick is to increment by 0x200 and use the odd number
(0x300) for atomic quiescence detection. Proxy collectors sure beat the
heck out of rwlock when it comes down to the iteration of large
collections of nodes... Here is an example test unit in Relacy:
 
https://pastebin.com/raw/f71480694
 
If interested, take careful notice of the following functions:
________________
collector& acquire()
{
// increment the master count _and_ obtain current collector.
unsigned int current =
m_current.fetch_add(0x20U, std::memory_order_acquire);
 
// decode the collector index.
return m_collectors[current & 0xFU];
}
 
void release(collector& c)
{
// decrement the collector.
unsigned int count =
c.m_count.fetch_sub(0x20U, std::memory_order_release);
 
// check for the completion of the quiescence process.
if ((count & 0xFFFFFFF0U) == 0x30U)
{
// odd reference count and drop-to-zero condition detected!
prv_quiesce_complete(c);
}
}
________________
 
 
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: