A Case for Relativistic Programming

479 views

Published on

Presentation by Philip W. Howard.
Paper and more information: http://soft.vub.ac.be/races/paper/the-case-for-relativistic-programming/

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
479
On SlideShare
0
From Embeds
0
Number of Embeds
210
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

A Case for Relativistic Programming

  1. 1. 10/21/2012 Races12A Case for RelativisticProgrammingPhilip W. HowardWest Virginia University Institute of TechnologyJonathan WalpolePortland State University
  2. 2. 10/21/2012 Races12 2EventsE1E2O1O2
  3. 3. 10/21/2012 Races12 3Triangle inequality: a + b >= cE1E2O2acbCausality
  4. 4. 10/21/2012 Races12 4Causalty in Computers• If computers were just wires, we’d be OK• Computers are wires + illogic
  5. 5. 10/21/2012 Races12 5illogic exampleA B DCC = malloc();C->data = data;C->next = D;B->next = C;rp-publish(B->next, C);
  6. 6. 10/21/2012 Races12 6Need for causal delaysA B DCCB->next = D;wait-for-readers();free(C);
  7. 7. 10/21/2012 Races12 7Rules for Placing RelativisticProgramming Primitives1. Write globally visible pointers withrp_publish()2. When performing two writes, one earlierin traversal order and one later intraversal order, separate the two withwait-for-readers()
  8. 8. 10/21/2012 Races12 8Relativistic vs. ConcurrentBalanced Trees•Relativistic Red Black Trees•Concurrent AVL TreesA practical concurrent binary search tree.PPoPP ’10; Bronson et al
  9. 9. 10/21/2012 Races12 9Concurrent AVL get20 V get(K k) {21 return (V)attemptGet(k, rootHolder, 1, 0);22 }2324 Object attemptGet(25 K k, Node node, int dir, long nodeV) {26 while (true) {27 Node child = node.child(dir);28 if (((node.version^nodeV) & IgnoreGrow) != 0)29 return Retry;30 if (child == null)31 return null;32 int nextD = k.compareTo(child.key);33 if (nextD == 0)34 return child.value;35 long chV = child.version;36 if ((chV & Shrinking) != 0) {37 waitUntilNotChanging(child);38 } else if (chV != Unlinked &&39 child == node.child(dir)) {40 if (((node.version^nodeV) & IgnoreGrow) != 0)41 return Retry;42 Object p = attemptGet(k, child, nextD, chV);43 if (p != Retry)
  10. 10. 10/21/2012 Races12 10Relativistic RBTree Getvoid *rb_find(rbtree *tree, long key){void *value;rbnode_t *node = tree->root;start_read();while (node != NULL) {if (key == node->key)break;else if (key < node->key)node = rp-dereference(node->left);elsenode = rp-dereference(node->right);}if (node != NULL)value = node->value;elsevalue = NULL;
  11. 11. 10/21/2012 Races12 11RBTree Delete
  12. 12. 10/21/2012 Races12 12RP Deleterbnode_t *new_node = rbnode_copy(swap);rp-publish(new_node->left, node->left);node->left->parent = new_node;rp-publish(new_node->right, node->right);node->right->parent = new_node;if (is_left(node))rp-publish(prev->left, new_node);elserp-publish (prev->right, new_node);new_node->parent = prev;// need to make sure new_node is seen before path to b is erasedwait-for-readers(tree->lock);prev = swap->parent;next = swap->right;rp-publish(prev->left, swap->right);if (swap->right != NULL) swap->right->parent = prev;
  13. 13. 10/21/2012 Races12 13075000001500000022500000300000000 18 35 53 70Read PerformanceReads/SecRead ThreadsNOLOCK readsNOLOCK cont. readsRP readsRP cont. readsccavl readsccavl cont. reads
  14. 14. 10/21/2012 Races12 140500001000001500002000000 18 35 53 70Contended Write PerformanceWrites/secRead ThreadsNOLOCK writesRP writesccavl writes
  15. 15. 10/21/2012 Races12 15Benefits of RP• High performance, Highly scalable reads• Simple Code• Strong correctness properties

×