The principles and practice of relativistic programming, a method to make concurrent programs faster by reducing synchronization. It uses a hash table example and the move operation to illustrate the concepts. Relativistic programming allows concurrent threads to access shared data at the same time and work with their observed 'relative' view of memory.
Download Scalable Concurrent Data Structures Through Relativistic Programming and more Study notes Computer Science in PDF only on Docsity!
Scalable Concurrent Data Structures Through
Relativistic Programming
Josh Triplett
April 29, 2008
Overview
Historical recap
(^) Principles and practice of relativistic programming
Hash table example and semantics
(^) Move operation
Implementation with relativistic programming
(^) Summary of principles and practice
Principles of relativistic programming
To make concurrent programs faster, do less synchronization.
Principles of relativistic programming
To make concurrent programs faster, do less synchronization.
(^) Allow concurrent threads to access shared data at the same time, even when doing modifications.
Putting the principles into practice
(^) One semantically significant change at a time
Putting the principles into practice
(^) One semantically significant change at a time
(^) Changes potentially become visible to other processors immediately, or after arbitrarily long delay
Putting the principles into practice
(^) One semantically significant change at a time
(^) Changes potentially become visible to other processors immediately, or after arbitrarily long delay
(^) Intermediate states must not violate semantics
Ordering not guaranteed unless explicitly requested
Hash table example
(^) Sample to illustrate relativistic programming methodology
Maps key to value
(^) Chaining: hash function maps key to bucket with list of nodes containing keys and values
(^) Lookup: use hash to find bucket, then check key of each node
Allows lookups in constant average time
(^) Used frequently in operating systems
Move operation semantics
(^) If a reader doesn’t see the old item, subsequent lookups of the
new item must succeed.
If a reader sees the new item, subsequent lookups of the old item must fail.
The move operation must not cause concurrent lookups for other items to fail
Readers must never block
Why the move operation?
Hash table buckets use linked lists
Move trivial to implement with critical sections
Insert then remove, or remove then insert
Intermediate states don’t matter
(^) Relativistic linked list implementations already exist
Move operation semantics not implementable using relativistic linked list operations
Previous solutions
Tombstone and Birthstone
(^) Variants on “insert then remove” or “remove then insert”
First insert a node which blocks readers that would otherwise see violated semantics
Both satisfy the first three required semantics
Both fail to satisfy the semantic that readers must never block
(^) Essentially mutual exclusion without the expensive synchronization instructions
Solution characteristics
Principles:
One semantically significant change at a time
Intermediate states must not violate semantics
(^) Need a new move operation specific to relativistic hash tables, making moves a single semantically significant change with no broken intermediate state
(^) Must appear to simultaneously move item to new bucket and change key
My solution
Cross-link end of new bucket to node in old bucket
(^) While target node appears in both buckets, change the key
My solution
Cross-link end of new bucket to node in old bucket
(^) While target node appears in both buckets, change the key
Need to resolve cross-linking safely, even for readers looking at the target node
(^) First move target node to the end of its bucket, so readers can’t miss later nodes