Remix.run Logo
▲ senderista 2 hours ago

I work on a commercial database marketed as "lock-free" and I can't tell you how many CAS spin loops I've seen with no backoff or iteration bounds.

▲cowlevel 16 minutes ago | parent | next [-]

If it only retries because a different thread made progress, it's lock-free and total work is bounded - even though one particular thread could get very unlucky, system-wide luck is conserved.

How much code's inside the CAS loop? If it's being held for less than (sticks finger in the wind) a few thousand of instructions then backoff or limits are actively counterproductive. That's how you're supposed to use a CAS loop.

If it's more, you shouldn't try to invent a more clever CAS loop, you should replace it with a mutex.

▲masklinn an hour ago | parent | prev [-]

Does the system provide ready made backoff and / or bounded CAS loop primitives? Because if you have to write the entire thing in full every time I can see why it’s get skipped.

▲cowlevel 14 minutes ago | parent [-]

Normally if you find yourself needing something like that, it means a CAS loop is the wrong tool for the job.