Practical Parallel Data Structures
Total Page:16
File Type:pdf, Size:1020Kb
Practical Parallel Data Structures Shahar Timnat Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 Practical Parallel Data Structures Research Thesis Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy Shahar Timnat Submitted to the Senate of the Technion | Israel Institute of Technology Sivan 5775 Haifa June 2015 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 This research was carried out under the supervision of Prof. Erez Petrank, in the Faculty of Computer Science. Some results in this thesis have been published as articles by the author and research collaborators in conferences during the course of the author's doctoral research period, the most up-to-date versions of which being: Keren Censor-Hillel, Erez Petrank, and Shahar Timnat. Help! In Proceedings of the 34th Annual ACM Symposium on Principles of Distributed Computing, PODC 2015, Donostia-San Sebastian, Spain, July 21-23, 2015. Erez Petrank and Shahar Timnat. Lock-free data-structure iterators. In Distributed Computing - 27th International Symposium, DISC 2013, Jerusalem, Israel, October 14-18, 2013. Proceedings, pages 224{238, 2013. Shahar Timnat, Anastasia Braginsky, Alex Kogan, and Erez Petrank. Wait-free linked-lists. In Principles of Distributed Systems, 16th International Conference, OPODIS 2012, Rome, Italy, December 18-20, 2012. Proceedings, pages 330{344, 2012. Shahar Timnat, Maurice Herlihy, and Erez Petrank. A practical transactional memory interface. In Euro-Par 2015 Parallel Processing - 21st International Conference, Vienna, Austria, August 24-28, 2015. Proceedings. Shahar Timnat and Erez Petrank. A practical wait-free simulation for lock-free data structures. In ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPOPP), pages 357{368, 2014. Acknowledgements I wish to thank my advisor, professor Erez Petrank, for the guidance and support he has given me. Throughout my studies, I have always been fully persuaded that he was the right advisor for me. Erez has always received me with his good-hearted smile, and he always had excellent advice to offer for my research and for life in general. For me, he is much more than a Ph.D. advisor. I would also like to extend a special word of thanks to professor Keren Censor-Hillel. The work with her has not only been highly productive, but also a lot of fun. Finally, I wish to thank professor Maurice Herlihy for his wise ideas which pointed me to the right directions, and for his kind attitude which made the experience very pleasant. The Technion's funding of this research is hereby acknowledged. I would also like to thank Mr. and Mrs. Jacobs for the Irwin and Joan Jacobs Fellowship, which I received in 2012 while I was still an M.Sc. student. My work was also supported by the Israeli Science Foundation grant No. 283/10, and by the United States - Israel Binational Science Foundation (BSF) grant No. 2012171. Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 Contents List of Figures Abstract 1 1 Introduction 3 1.1 Wait-Free Linked-Lists . 4 1.2 A General Wait-Free Simulation for Lock-Free Data Structures . 5 1.3 On the relations between Wait-Freedom and Help . 6 1.4 Iterator . 8 1.5 Harnessing HTM to Support Data Structures with Progress Guarantees 10 1.6 Outline of this Thesis . 12 2 Wait-Free Linked-Lists 13 2.1 Introduction . 13 2.2 An Overview of the Algorithm . 13 2.3 The Algorithm . 15 2.3.1 The Underlying Data Structures . 16 2.3.2 The Helping Mechanism . 17 2.3.3 The Search Methods . 17 2.3.4 The Insert Operation . 18 2.3.5 The Delete Operation . 21 2.3.6 The Contains Operation . 24 2.3.7 Memory management . 24 2.4 A Correctness Proof . 24 2.4.1 Highlights . 25 2.4.2 General . 26 2.4.3 Definitions . 26 2.4.4 General List Invariants . 29 2.4.5 The Insert Operation . 40 2.4.6 The Delete Operation . 46 2.4.7 Wait-Freedom . 51 2.4.8 Final Conclusion . 54 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 2.5 Linearization Points . 54 2.6 A Fast-Path-Slow-Path Extension . 55 2.6.1 overview . 55 2.6.2 The Delayed Help Mechanism . 56 2.6.3 The Search Method . 57 2.6.4 The Insert Operation . 57 2.6.5 The Delete Operation . 57 2.6.6 Linearization Points . 60 2.6.7 The Contains Operation and Handling Infinite Insertions . 60 2.7 Performance . 61 2.8 Conclusion . 63 3 A Practical Wait-Free Simulation for Lock-Free Data Structures 65 3.1 Introduction . 65 3.2 Additional Related Work . 66 3.3 Transformation overview . 66 3.4 Model and General Definitions . 68 3.5 Typical Lock-Free Algorithms . 69 3.5.1 Motivating Discussion . 69 3.5.2 Notations and Definitions Specific to the Normalized Form. 70 3.6 Normalized Lock-Free Data Structures . 73 3.6.1 The Normalized Representation . 74 3.7 Transformation Details . 76 3.7.1 The Help Queue and the Operation Record . 77 3.7.2 Giving Help . 78 3.8 Correctness . 82 3.8.1 Correctness of the executeCASes Implementation . 83 3.8.2 Linearizability and WaitFreedom . 99 3.9 On the Generality of the Normalized Form . 109 3.10 Examples: the Transformation of Four Known Algorithms . 110 3.10.1 Harris's linked-list . 111 3.10.2 Binary Search Tree . 112 3.10.3 Skiplist . 115 3.10.4 The Linked-List of Fomitchev and Ruppert . 117 3.11 Optimizations . 119 3.11.1 Using the Original Algorithm for the Fast Path . 119 3.11.2 Avoiding versions . 120 3.12 Performance . 121 3.12.1 Memory Management . 121 3.12.2 Our Wait-Free Versions vs. the Original Lock-Free Structures . 121 3.12.3 Our Wait-Free Transformation vs. a Universal Construction . 122 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 4 Help! 127 4.1 Introduction . 127 4.2 Additional Related Work . 128 4.3 Model and Definitions . 128 4.4 What is Help? . 130 4.4.1 Intuitive Discussion . 130 4.4.2 Help Definition . 131 4.4.3 General Observations . 133 4.5 Exact Order Types . 133 4.5.1 Generalizing the Proof To Cover the Fetch&Add Primitive . 140 4.6 Global View Types . 142 4.6.1 From Single Scanner Snapshot to Global View Types . 151 4.7 Max Registers . 153 4.8 Types that Do Not Require Help . 157 4.8.1 A Help-Free Wait-Free Set . 157 4.8.2 A Help-Free Wait-Free Max Register . 158 4.9 A Universality of Fetch-And-Cons . 159 4.10 Discussion . 160 5 Lock-Free Data-Structure Iterators 163 5.1 Introduction . 163 5.2 Goals and Limitations . 164 5.3 Jayanti's Single Scanner Snapshot . 165 5.4 From Single Scanner Snapshot to Multiple Data Structure Snapshots . 167 5.4.1 Reporting the Operations of Other Threads . 167 5.4.2 Supporting Multiple Snapshots . 167 5.5 The Data Structure Snapshot Algorithm . 168 5.5.1 The Reporting Mechanism . 168 5.5.2 Performing a Data Structure Snapshot . 171 5.5.3 Memory Reclamation . 172 5.6 The Snap-Collector Object . 174 5.6.1 The Snap-Collector Implementation . 176 5.6.2 Some Simple Optimizations . 178 5.7 Proof . 179 5.7.1 Overview . 180 5.7.2 Definitions . 181 5.7.3 Constructing the Whole-Order . 186 5.7.4 Visibility Properties . 186 5.7.5 Sequential and Real-Time Consistency of the Whole-Order. 198 5.7.6 Adjusting the Proof for Multiple Scanners . 202 5.7.7 Linearizability of the Snap-Collector . 203 Technion - Computer Science Department - Ph.D. Thesis PHD-2015-06 - 2015 5.8 Performance . 204 5.9 Conclusion . 206 6 A Practical Transactional Memory Interface 209 6.1 Introduction . 209 6.2 Additional Related Work . 209 6.3 The MCMS Operation . ..