Read Copy Update
Read copy update, or RCU, is a synchronization technique that makes reads extremely cheap, often free of any lock or atomic instruction, while still allowing concurrent writers. It shines for data that is read far more often than it is written.
The name describes the writer path. To change shared data a writer:
- Reads the current version of the structure.
- Copies it and makes the change on the private copy.
- Updates the shared pointer to publish the new copy with a single atomic store.
Readers simply follow the pointer. A reader that grabbed the old pointer keeps using the old copy safely. The hard part is knowing when it is safe to reclaim the old version. The writer must wait for a grace period during which every reader that might still hold the old pointer has finished its read side critical section.
Key ideas:
- Cheap reads Readers take no lock, so read scaling is nearly perfect.
- Deferred reclamation Old data is freed only after a grace period guarantees no reader references it.
- Writer cost Writers do more work and may serialize among themselves.
RCU is heavily used inside operating system kernels for structures like routing tables and linked lists where reads dominate.
Key idea
RCU lets readers run lock free by following a pointer while writers publish updated copies and reclaim old ones only after a grace period drains all readers.