Download presentation
Presentation is loading. Please wait.
1
11/2/20111 The Ordering Requirements of Relativistic and Reader-Writer Locking Approaches to Shared Data Access Philip W. Howard with Jonathan Walpole, Josh Triplett, Paul E. McKenney
2
11/2/20112 Outline The Problem The RWL Solution The RP Solution Other problems and their solutions Multiple Writers Performance
3
11/2/20113 The Problem ABC AC
4
11/2/20114 The Problem obtain refdrop ref unlinkreclaim obtain refdrop ref Reader 1 Reader 2 Writer
5
11/2/20115 The Problem void init(stuff *node) { node->a = COMPUTE_A; node->b = COMPUTE_B; node->initd = TRUE; } while (!node->initd) {} if (node->a) drop_nuke(); if (node->b) drop_napalm();
6
11/2/20116 The Problem void init(stuff *node) { int value; value = some_computation; node->a = COMPUTE_A; node->b = COMPUTE_B; node->initd = value; }
7
11/2/20117 The Problem void init(stuff *node) { node->a = COMPUTE_A; node->b = COMPUTE_B; node->initd = TRUE; } while (!node->initd) {} if (node->a) drop_nuke(); if (node->b) drop_napalm();
8
11/2/20118 The Problem Compiler reordering CPU reordering Memory System reordering
9
11/2/20119 How are these dependencies maintained? obtain refdrop ref unlinkreclaim obtain refdrop ref Reader 1 Reader 2 Writer
10
11/2/201110 How does → work? Thread 1 A: a=1; Thread 2 B: if (a) A → B else B → A
11
11/2/201111 How does work? Thread 1 A: a=1; mb(); C: c=1; Thread 2 while (!a) B: A B Thread 3 if (c) D: A D
12
11/2/201112 With Reader-Writer Locks obtain refdrop ref unlinkreclaim read-lockread-unlock write-lockwrite-unlock
13
11/2/201113 With Reader-Writer Locks obtain refdrop ref unlinkreclaim read-lockread-unlock write-lock write-unlock
14
11/2/201114 With Reader-Writer Locks obtain refdrop ref unlinkreclaim read-lock read-unlock write-lockwrite-unlock
15
11/2/201115 Locking primitives must Impose the semantics of the lock Prevent compiler, CPU, or Memory system from reordering operations across them
16
11/2/201116 With Relativistic Programming obtain refdrop ref start-waitend-wait start-readend-read unlinkreclaim
17
11/2/201117 With Relativistic Programming obtain refdrop ref start-waitend-wait start-readend-read unlinkreclaim
18
11/2/201118 RP primitives must Impose the semantics of wait-for-readers Prevent compiler, CPU, or Memory system from reordering operations across them
19
11/2/201119 Outline The Problem The RWL Solution The RP Solution Other problems and their solutions Insert Move Down Move Up General Case Multiple Writers Performance
20
11/2/201120 Insert CDE CE
21
11/2/201121 Insert obtain refderef initlink obtain refderef Reader 1 Reader 2 Writer
22
11/2/201122 How does work? Thread 1 A: a=1; mb(); C: c=1; Thread 2 while (!a) B: A B Thread 3 if (c) D: A D
23
11/2/201123 Insert Use rp-publish to perform link operation
24
11/2/201124 Move Down A B C D F G E H A B C D F GE H
25
11/2/201125 Move Down A B C D F G E H A B C D F GE H F’ A B C D GE H 1.init F’ 2.link F’ 3.unlink F
26
11/2/201126 Move Down init(F’) link(F’)unlink(F) reclaim(F) deref(H)deref(F)deref(D)deref(E) A B C D F G E H A B C D F G E H F’ A B C D GE H
27
11/2/201127 Move Down init(F’) link(F’)unlink(F) reclaim(F) deref(H)deref(F)deref(D)deref(F’) A B C D F G E H A B C D F G E H F’ A B C D GE H deref(E)
28
11/2/201128 Move Down init(F’) link(F’)unlink(F) reclaim(F) deref(H)deref(D)deref(F’) A B C D F G E H A B C D F G E H F’ A B C D GE H deref(E)
29
11/2/201129 RBTree Delete with Swap (Move Up) D A B E C F null D A B E C F C’ AE D F
30
11/2/201130 Move Up init(C’) link(C’)unlink(C) reclaim(C) deref(F)deref(C’) D A B E C F null D A B E C F C’ AE D F
31
11/2/201131 Move Up init(C’) link(C’)unlink(C) reclaim(C) deref(F)deref(B)deref(E) D A B E C F deref(C) null D A B E C F C’ AE D F
32
11/2/201132 The General Case Mutable vs. Immutable data
33
11/2/201133 The General Case for Writers Copy nodes to update immutable data or to make a collection of updates appear atomic Use rp-publish to update mutable data Use wait-for-readers when updates are in traversal order ABC
34
11/2/201134 The General Case for Readers Use rp-read for reading mutable data Only dereference mutable data once if (node->next->key == key) { return node->next->value; }
35
11/2/201135 Outline The Problem The RWL Solution The RP Solution Other problems and their solutions Multiple Writers Performance
36
11/2/201136 Multiple Writers W R2 R1
37
11/2/201137 Multiple Writers W1 Reader W2
38
11/2/201138 The phone company Can’t wait to get my new phone Can’t wait to ditch this phone Can’t wait to ditch this phone Where’s my phone book?
39
11/2/201139 Multiple Writers W1 Reader W2 wait-for-readers W1 Reader W2
40
11/2/201140 RP vs RWL delays W1 Reader W2 RP W1 Reader W2 reader pref W1 Reader W2 writer pref W1 Reader W2 TORP
41
11/2/201141 Trigger Events RP RWLR RWLW
42
11/2/201142 Outline The Problem The RWL Solution The RP Solution Other problems and their solutions Multiple Writers Performance
43
11/2/201143 How does work? Thread 1 A: a=1; mb(); C: c=1; Thread 2 while (!a) B: A B Thread 3 if (c) D: A D
44
11/2/201144 Reader-Writer Locks read-unlock write-lockwrite-unlock read-lock read-unlockread-lock
45
11/2/201145 Reader-Writer Locks Reader while (writing) {} reading=1; Writer while (reading) {} writing=1;
46
11/2/201146 Relativistic Programming start-waitend-wait start-readend-read start-readend-read
47
11/2/201147 Relativistic Programming start-read(i) { reader[i]=1; } end-read(i) { reader[i]=0; } start-wait() {} end-wait() { for (i) { while (reader[i]) {} }
48
11/2/201148 Relativistic Programming start-read(i) { reader[i]=Epoch; } end-read(i) { reader[i]=0; } start-wait() { Epoch++; my_epoch = Epoch; } end-wait() { for (i) { while (reader[i] && reader[i] < my_epoch) {} }
49
11/2/201149 Performance Benefits to RP Less expensive read-side primitives Less serialization / more concurrency Less waiting
50
11/2/201150 Benchmarked Methods nolockNo synchronization rpRelativistic Programming torpTotally Ordered RP rwlrReader-Writer Lock Read preference rwlwReader-Writer Lock Write preference
51
11/2/201151 Read Performance (size=1)
52
11/2/201152 Read Performance (size=1000)
53
11/2/201153 Update Scalability
54
11/2/201154 Update Scalability part 2
55
11/2/201155 Update Scalability (part 3)
56
11/2/201156 Conclusions Correctness can be preserved by limiting allowable orderings RP read primitives are less expensive than RWL primitives RP allows more concurrency and less waiting
57
11/2/201157 Conclusions RP can preserve both correctness and scalability or reads
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.