Docsity

Scalable Data Structures with Relativistic Programming: A Solution to the Need to Agree - , Study notes of Computer Science

Partial preview of the text

Download Scalable Data Structures with Relativistic Programming: A Solution to the Need to Agree - and more Study notes Computer Science in PDF only on Docsity!

Scalable Data Structures with RelativisticProgramming

Josh TriplettJune 3, 2009

Review

• Motiviations for relativistic programming: • • • Correctness requires performancePerformance requires scalabilityScale by reducing the need to agree

• • What does “need to agree” mean?Why do we think need to agree matters?

Hash table example

• • • Sample to illustrate relativistic programming methodologyMaps key to valueChaining: hash function maps key to bucket with list of nodescontaining keys and values

• • • Lookup: use hash to find bucket, then check key of each nodeAllows lookups in constant average timeUsed frequently in operating systems

Move operation

a ...

b

n 1 n 2 n 3

n 4 n 5

key^ “old”

Move operation semantics

• • If a reader doesn’t see the old item, subsequent lookups of thenew item must succeed.If a reader sees the new item, subsequent lookups of the olditem must fail.

• • The move operation must not cause concurrent lookups forother items to failSemantics based on filesystems

Why the move operation?

• • Trivial to implement with mutual exclusionHash table buckets use linked lists • • Insert then remove, or remove then insertIntermediate states don’t matter

• • Relativistic linked list implementations already existMove operation semantics not implementable using relativisticlinked list operations (insert and remove)

Solution characteristics

• • Principles:Need a new move operation specific to relativistic hash tables, • • One semantically significant change at a timeIntermediate states must not violate semantics

• making moves a single semantically significant change with nobroken intermediate stateMust appear to simultaneously move item to new bucket andchange key

a My solution

b^ ...^ n^ n^14 nn^25 n^3 key^ “old”

• Cross-link end of new bucket to node in old bucket

a My solution

b^ ...^ n^ n^14 nn^25 n^3 key^ “new”

• • • Cross-link end of new bucket to node in old bucketWhile target node appears in both buckets, change the keyNeed to resolve cross-linking safely, even for readers looking atthe target node

• • First move target node to the end of its bucket, so readerscan’t miss later nodesMemory barriers

Benchmarking with rcuhashbash

• • • • Run one thread per CPU.Continuous loop: randomly read or writeConfigurable algorithm and read:write ratioRun for 30 seconds, count reads and writes

Results, 999999:1 read:write ratio, writes

Writes CPUs

table_spinlock^ table_rwlock^ spinlock^ rcu_seq^ rwlock^ rcu

Results, 999:1 read:write ratio, reads

1e+09 0 2e+09^ 3e+

4e+09^ 5e+

6e+09^ 7e+

1 2 4 8 16 32 64

Reads CPUs

table_spinlock^ table_rwlock^ rcu_seq^ spinlock^ rwlock^ rcu

Results, 1:1 read:write ratio, reads

5e+07 0

1.5e+08 1e+

2.5e+08 2e+

1 2 4 8 16 32 64

Reads CPUs

table_spinlock^ table_rwlock^ spinlock^ rcu_seq^ rwlock^ rcu

Results, 1:1 read:write ratio, writes

2e+07 0 4e+07^ 6e+

8e+07^ 1e+

1.2e+

1 2 4 8 16 32 64

Writes CPUs

table_spinlock^ table_rwlock^ spinlock^ rcu_seq^ rwlock^ rcu