Lock-Free Concurrent Search

Total Page:16

File Type:pdf, Size:1020Kb

Lock-Free Concurrent Search THESIS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY Lock-free Concurrent Search BAPI CHATTERJEE Division of Networks and Systems Department of Computer Science and Engineering CHALMERS UNIVERSITY OF TECHNOLOGY Göteborg, Sweden 2017 Lock-free Concurrent Search Bapi Chatterjee Copyright c Bapi Chatterjee, 2017. ISBN: 978-91-7597-483-5 Series number: 4164 ISSN 0346-718X Technical report 136D Department of Computer Science and Engineering Distributed Computing and Systems Research Group Division of Networks and Systems Chalmers University of Technology SE-412 96 GÖTEBORG, Sweden Phone: +46 (0)31-772 10 00 Author e-mail: [email protected], [email protected] Printed by Chalmers Reproservice GÖTEBORG, Sweden 2017 Lock-free Concurrent Search Bapi Chatterjee Division of Networks and Systems, Chalmers University of Technology ABSTRACT The contemporary computers typically consist of multiple computing cores with high compute power. Such computers make excellent concurrent asyn- chronous shared memory system. On the other hand, though many celebrated books on data structure and algorithm provide a comprehensive study of se- quential search data structures, unfortunately, we do not have such a luxury if concurrency comes in the setting. The present dissertation aims to address this paucity. We describe novel lock-free algorithms for concurrent data structures that target a variety of search problems. (i) Point search (membership query, predecessor query, nearest neighbour query) for 1-dimensional data: Lock-free linked-list; lock-free internal and external binary search trees (BST). (ii) Range search for 1-dimensional data: A range search method for lock- free ordered set data structures - linked-list, skip-list and BST. (iii) Point search for multi-dimensional data: Lock-free kD-tree, specially, a generic method for nearest neighbour search. We prove that the presented algorithms are linearizable i.e. the concurrent data structure operations intuitively display their sequential behaviour to an ob- server of the concurrent system. The lock-freedom in the introduced algorithms guarantee overall progress in an asynchronous shared memory system. We present the amortized analysis of lock-free data structures to show their efficiency. Moreover, we provide sample implementations of the algorithms and test them over extensive micro-benchmarks. Our experiments demonstrate that the implementations are scalable and perform well when compared to related existing alternative implementations on common multi-core computers. Our focus is on propounding the generic methodologies for efficient lock- free concurrent search. In this direction, we present the notion of help-optimality, which captures the optimization of amortized step complexity of the operations. In addition to that, we explore the language-portable design of lock-free data structures that aims to simplify an implementation from programmer’s point of view. Finally, our techniques to implement lock-free linearizable range search and nearest neighbour search are independent of the underlying data structures and thus are adaptive to similar data structures. Keywords: Data Structure, Search, Range Search, Nearest Neighbour Search, Con- current, Concurrency, Lock-free, Lock-based, Blocking, Non-blocking, Wait-free, Lin- earizable, Linearizability, Binary Search Tree, Linked-list, kD-tree, Lock-free-kD-tree, Amortized Complexity, Help-aware, Help-optimal, Language-portable, Synchronization ii To my Mother & my late Father iii iv Dedication Acknowledgements First of all, I would like to express my gratitude to my supervisor Prof. Philippas Tsigas for his constant support and guidance. Without his generous help, this thesis would not have been possible. I also thank the graduate committee members - Prof. Thierry Coquand, As- sociate Prof. Marina Papatriantafilou, Prof. Jan Jonsson and former committee members Prof. Koen Claessen and Prof. Gerardo Schneider for their kind sup- port and helpful suggestions during the discussions in my Ph.D. study follow-up meetings. I am honored to have Prof. Pascal Felber as the opponent of my Ph.D. thesis defense. My sincere thanks to the members of the grading committee: Associate Prof. Paolo Romano, Associate Prof. Pedro Petersen Moura Trancoso, Prof. Stefanos Kaxiras, and Prof. Ulf Assarsson. I also take this opportunity to thank my previous supervisors Prof. Subodh Kumar (Dept of CS&E, IIT Delhi, India) and Prof. Aparna Mehra (Dept of Mathematics, IIT Delhi, India), whose guidance during my master’s studies helped me shape my thinking and motivated me enough to join the doctoral studies. I am extremely grateful to the Swedish Foundation for Strategic Research (SSF) who funded me as a full-time Ph.D. student for five years in the research project “Software Abstractions for Heterogeneous Computers (SCHEME)”. I thank the project co-leaders Prof. Per Stenström and Prof. Ulf Assarsson and other members in the project SCHEME with whom I truly enjoyed my collab- oration. Next, I would like to thank everybody in the Distributed Computing and Systems group, of which I am proud to be a member: Amir, Aras, Bashr, Char- alampos, Elad, Hannah, Ioannis, Iosif, Ivan, Olaf, Magnus, Thomas, and Vin- cenzo. I thank former members of the group, with whom I spent some of the most enjoyable moments during my Ph.D.: Andreas, Daniel, Farnaz, Giorgos, Oscar, Paul, and Valentin. My special thanks to my former office-mates, Nhan and Zhang, for the fun time and interesting discussions on topics confined to an v vi Acknowledgements uncountable number of domains. I also wish all the best to the youngsters in the group. It will remain incomplete without mentioning former members of the de- partment: Bhavishya, Chien-Chung, and Madhavan, with whom I shared not just many vegetarian meals but also some unforgettable moments in Göteborg. I also take this opportunity to thank the staff and the Ph.D. students at the Department of Computer Science and Engineering where I am privileged to be a member. It is thanking them for their efforts to make the department such a great place to work. I would like to especially thank Eva, Rebecca, Peter, Tiina, and Tomas for always being helpful and responsive. Bapi Chatterjee Göteborg Contents Abstract ::::::::::::::::::::::::::::::::: i Dedication :::::::::::::::::::::::::::::::: iii Acknowledgements ::::::::::::::::::::::::::: v Contents and Publications ::::::::::::::::::::::: xi Part I Introduction 1 1. Introduction ::::::::::::::::::::::::::::: 3 1.1 Search Algorithms........................3 1.1.1 Introduction to Search..................3 1.1.2 Search Data Structures..................5 1.2 Concurrent Data Structures....................8 1.2.1 Synchronization Algorithm................8 1.2.2 Concurrent Search Data Structures............ 15 1.3 Our Contributions......................... 19 2. System Model and Preliminaries :::::::::::::::::: 21 2.1 System Model........................... 21 2.2 Correctness and Complexity................... 24 2.2.1 Correctness........................ 24 2.2.2 Complexity........................ 26 Part II Lock-free 1-dimensional Point Search 29 3. Help-optimal and Language-portable Lock-free Concurrent Data Struc- tures ::::::::::::::::::::::::::::::::: 31 vii viii Contents 3.1 Introduction............................ 32 3.1.1 Overview......................... 32 3.1.2 Related Work....................... 35 3.2 Help-optimality: Motivation................... 36 3.3 Help-optimal Lock-free Linked-list................ 40 3.3.1 Design.......................... 40 3.3.2 Correctness and Lock-freedom.............. 44 3.3.3 Amortized Step Complexity............... 45 3.4 Help-optimal Lock-free BST................... 45 3.4.1 Design.......................... 47 3.4.2 Correctness and Lock-freedom.............. 52 3.5 Help-optimality: Specification.................. 53 3.6 Experimental Evaluation..................... 54 3.6.1 Experimental Set-up................... 54 3.6.2 Performance Results and Discussion........... 56 4. Amortized Complexity of Lock-Free Internal Binary Search Tree : 63 4.1 Introduction............................ 63 4.2 Preliminaries........................... 65 4.3 Our Algorithm.......................... 67 4.3.1 Design Fundamentals................... 67 4.3.2 The Lock-free Algorithm................. 68 4.4 Correctness and Complexity................... 83 4.4.1 Linearizability...................... 85 4.4.2 Lock-Freedom...................... 86 4.4.3 Complexity........................ 87 Part III Lock-free 1-dimensional Range Search 93 5. Lock-free Linearizable 1-Dimensional Range Queries ::::::: 95 5.1 Introduction............................ 95 5.1.1 Background........................ 95 5.1.2 Related work....................... 97 5.1.3 A summary of our work................. 97 5.2 The Lock-Free Range Search................... 100 5.2.1 Snap-collector implementation.............. 100 5.2.2 Lock-free linearizable range search algorithm...... 104 5.2.3 Range queries in a lock-free binary search tree..... 111 5.3 Correctness proof......................... 113 Contents ix 5.3.1 Proof........................... 113 5.4 Experimental Evaluation..................... 117 5.4.1 Experimental Setup.................... 117 5.4.2 Observations and Discussion............... 118 Part IV Lock-free Multidimensional Point Search 121 6. Concurrent Linearizable Nearest Neighbour Search in LockFree-kD- tree :::::::::::::::::::::::::::::::::: 123 6.1 Introduction............................ 123 6.1.1 Background.......................
Recommended publications
  • All-Near-Neighbor Search Among High-Dimensional Data Via Hierarchical Sparse Graph Code Filtering
    All-Near-Neighbor Search Among High-Dimensional Data via Hierarchical Sparse Graph Code Filtering by Alexandros-Stavros Iliopoulos Department of Computer Science Duke University Date: Approved: Xiaobai Sun, Advisor Pankaj K. Agarwal Nikos Pitsianis Carlo Tomasi Dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in the Department of Computer Science in the Graduate School of Duke University 2020 Abstract All-Near-Neighbor Search Among High-Dimensional Data via Hierarchical Sparse Graph Code Filtering by Alexandros-Stavros Iliopoulos Department of Computer Science Duke University Date: Approved: Xiaobai Sun, Advisor Pankaj K. Agarwal Nikos Pitsianis Carlo Tomasi An abstract of a dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in the Department of Computer Science in the Graduate School of Duke University 2020 Copyright c 2020 by Alexandros-Stavros Iliopoulos All rights reserved except○ the rights granted by the Creative Commons Attribution-Noncommercial Licence Abstract This thesis addresses the problem of all-to-all near-neighbor (all-NN) search among a large dataset of discrete points in a high-dimensional feature space endowed with a distance metric. Near-neighbor search is fundamental to numerous computational tasks arising in modern data analysis, modeling, and knowledge discovery. The ac- curacy and efficiency of near-neighbor search depends on the underlying structure of the dataset. In emerging data-driven analysis applications, the dataset is not necessarily stationary, the structure is not necessarily built once for all queries, and search is not necessarily limited to a few query points. To facilitate accurate and efficient near-neighbor search in a stationary or dynamic dataset, we makeasys- tematic investigation of all-NN search at multiple resolution levels, with attention to several standing or previously overlooked issues associated with high-dimensional feature spaces.
    [Show full text]
  • Parallel K Nearest Neighbor Graph Construction Using Tree-Based Data Structures
    Parallel k Nearest Neighbor Graph Construction Using Tree-Based Data Structures Nazneen Rajani Kate McArdle Inderjit S. Dhillon Dept. of Computer Science The Center for Advanced Dept. of Computer Science University of Texas at Austin Research in Software University of Texas at Austin Austin, TX 78712-1188, USA Engineering Austin, TX 78712-1188, USA [email protected] University of Texas at Austin [email protected] Austin, TX 78712-1188, USA [email protected] ABSTRACT points in a d dimensional space by dividing the space into Construction of a nearest neighbor graph is often a neces- several partitions [3]. Each d-dimensional point in a data sary step in many machine learning applications. However, set is represented by a node in the k-d tree, and every level constructing such a graph is computationally expensive, es- of the tree splits the space along one of the d dimensions. pecially when the data is high dimensional. Python's open Thus every node that is not a leaf node implicitly generates a source machine learning library Scikit-learn uses k-d trees hyperplane perpendicular to the dimension on which its level and ball trees to implement nearest neighbor graph construc- splits, and all nodes in the node's left subtree fall to the left tion. However, this implementation is inefficient for large of the hyperplane, while all nodes in the node's right subtree datasets. In this work, we focus on exploiting these under- fall to the right of the hyperplane. A ball tree, like the k- lying tree-based data structures to optimize parallel execu- d tree, is also a binary tree data structure that organizes tion of the nearest neighbor algorithm.
    [Show full text]
  • Thesis Efficient and Accurate Non-Metric K-NN Search with Applications to Text Matching Leonid Boytsov
    Thesis Efficient and Accurate Non-Metric k-NN Search with Applications to Text Matching Leonid Boytsov CMU-LTI-18-006 Language Technologies Institute School of Computer Science Carnegie Mellon University 5000 Forbes Ave., Pittsburgh, PA 15213 www.lti.cs.cmu.edu Thesis Committee: Dr. Eric Nyberg, Carnegie Mellon University, Chair Dr. Jamie Callan, Carnegie Mellon University Dr. Alex Hauptmann, Carnegie Mellon University Dr. James Allan, University of Massachusetts Amherst Dr. J. Shane Culpepper, the Royal Melbourne Institute of Technology Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy. Copyright c 2018 Leonid Boytsov Abstract In this thesis we advance state-of-the-art of the non-metric k-NN search by carry- ing out an extensive empirical evaluation (both and intrinsic) of generic methods for k-NN search. This work contributes to establishing a collection of strong benchmarks for data sets with generic distances. We start with intrinsic evaluations and demonstrate that non metric k-NN search is a practical and reasonably accurate tool for a wide variety of complex distances. However, somewhat surprisingly, achieving good performance does not require distance mapping/proxying via metric learning or distance symmetrization. Existing search methods can often work directly with non-metric and non-symmetric distances. They outperform the filter-and-refine approach relying on the distance symmetrization in the filtering step. Intrinsic evaluations are complemented with extrinsic evaluations in a realistic text retrieval task. In doing so, we make a step towards replacing/complementing classic term-based retrieval with a generic k-NN search algorithm. To this end we use a similarity function that takes into account subtle term associations, which are learned from a parallel monolingual corpus.
    [Show full text]
  • Parallel K Nearest Neighbor Graph Construction Using Tree-Based Data Structures
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by UPCommons. Portal del coneixement obert de la UPC Parallel k Nearest Neighbor Graph Construction Using Tree-Based Data Structures Nazneen Rajani Kate McArdle Inderjit S. Dhillon Dept. of Computer Science The Center for Advanced Dept. of Computer Science University of Texas at Austin Research in Software University of Texas at Austin Austin, TX 78712-1188, USA Engineering Austin, TX 78712-1188, USA [email protected] University of Texas at Austin [email protected] Austin, TX 78712-1188, USA [email protected] ABSTRACT points in a d dimensional space by dividing the space into Construction of a nearest neighbor graph is often a neces- several partitions [3]. Each d-dimensional point in a data sary step in many machine learning applications. However, set is represented by a node in the k-d tree, and every level constructing such a graph is computationally expensive, es- of the tree splits the space along one of the d dimensions. pecially when the data is high dimensional. Python's open Thus every node that is not a leaf node implicitly generates a source machine learning library Scikit-learn uses k-d trees hyperplane perpendicular to the dimension on which its level and ball trees to implement nearest neighbor graph construc- splits, and all nodes in the node's left subtree fall to the left tion. However, this implementation is inefficient for large of the hyperplane, while all nodes in the node's right subtree datasets.
    [Show full text]
  • Adaptive Bounding Volume Hierarchies for Efficient Collision
    M¨alardalen University Press Dissertations No.71 Adaptive Bounding Volume Hierarchies for Efficient Collision Queries Thomas Larsson January 2009 School of Innovation, Design and Engineering M¨alardalen University V¨aster˚as, Sweden Copyright c Thomas Larsson, 2009 ISSN 1651-4238 ISBN 978-91-86135-18-8 Printed by Arkitektkopia, V¨aster˚as, Sweden Distribution: M¨alardalen University Press Abstract The need for efficient interference detection frequently arises in computer graphics, robotics, virtual prototyping, surgery simulation, computer games, and visualization. To prevent bodies passing directly through each other, the simulation system must be able to track touching or intersecting geometric primitives. In interactive simulations, in which millions of geometric primitives may be involved, highly efficient colli- sion detection algorithms are necessary. For these reasons, new adaptive collision detection algorithms for rigid and different types of deformable polygon meshes are proposed in this thesis. The solutions are based on adaptive bounding volume hierarchies. For deformable body simulation, different refit and reconstruction schemes to efficiently update the hierarchies as the models deform are presented. These methods permit the models to change their entire shape at every time step of the simulation. The types of deformable models considered are (i) polygon meshes that are deformed by arbitrary vertex repositioning, but with the mesh topology preserved, (ii) models deformed by linear morphing of a fixed number of reference meshes, and (iii) models undergoing completely unstructured relative motion among the geometric primitives. For rigid body simulation, a novel type of bounding volume, the slab cut ball, is introduced, which improves the culling efficiency of the data structure significantly at a low storage cost.
    [Show full text]
  • Ball*-Tree: Efficient Spatial Indexing for Constrained Nearest-Neighbor
    Ball*-tree: Efficient spatial indexing for constrained nearest-neighbor search in metric spaces Mohamad Dolatshah, Ali Hadian, and Behrouz Minaei-Bidgoli Iran University of Science and Technology fdolatshah.mohammad,[email protected], b [email protected] Abstract. Emerging location-based systems and data analysis frame- works requires efficient management of spatial data for approximate and exact search. Exact similarity search can be done using space partitioning data structures, such as KD-tree, R*-tree, and ball-tree. In this paper, we focus on ball-tree, an efficient search tree that is specific for spatial queries which use euclidean distance. Each node of a ball-tree defines a ball, i.e. a hypersphere that contains a subset of the points to be searched. In this paper, we propose ball*-tree, an improved ball-tree that is more efficient for spatial queries. Ball*-tree enjoys a modified space partition- ing algorithm that considers the distribution of the data points in order to find an efficient splitting hyperplane. Also, we propose a new algorithm for KNN queries with restricted range using ball*-tree, which performs better than both KNN and range search for such queries. Results show that ball*-tree performs 39%-57% faster than the original ball-tree algo- rithm. Keywords: Ball-tree, Constrained NN, Spatial indexing, Eigenvector analysis, Range search. 1 Introduction Nearest neighbor (NN) search search is of great importance in many data an- alytics applications such as Geographical Information Systems (GIS), machine learning, computer vision, and robotics. Given a query point q, a common task arXiv:1511.00628v1 [cs.DB] 2 Nov 2015 is to search for the k closest points to q among all points in a dataset.
    [Show full text]