Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"There is hopeful symbolism in the fact that flags do not wave in a vacuum." -- Arthur C. Clarke


devel / comp.arch / Some older tricks...

SubjectAuthor
o Some older tricks...Chris M. Thomasson

1
Some older tricks...

<unkqtu$2779a$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36771&group=comp.arch#36771

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.arch
Subject: Some older tricks...
Date: Tue, 9 Jan 2024 17:12:29 -0800
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <unkqtu$2779a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 10 Jan 2024 01:12:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="895382d1d7b553b27dcc9759fae19b1a";
logging-data="2333994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hn8W56S+P4pKhr305TD3a1J6VoJDLqR4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VR0bESLoRK9pVWjWg9p2QL1sKXU=
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 10 Jan 2024 01:12 UTC

Fwiw,

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!

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);
}
}
________________

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor