How to implement C++26 RCU

Denis Yaroshevskiy

This talk

Motivational Example

std::shared_ptr + mutex

Atomic Shared Ptr

Raw pointer

Using RCU

implementing basic rcu

Testing using relacy

RCU smoke test

RCU (broken)

Bug report

low level concurrency in c++

Approaches to Understanding

  • C++ standard
  • Understand hardware first
  • Made up hardware model

What does relaxed do?

  • "atomicity"
  • while (!done.load(...))

What do acquire / release do?

  • release store waits for previous stores to leave the buffer
  • acquire load disallows the following reads to come from the buffer
  • nothing in the speicification looks like what I said
  • [atomics.order] release ... synchronizes with ... acquire ... takes its value

RCU test