Wait-Free Dynamic Transactions for Linked Data Structures
Total Page:16
File Type:pdf, Size:1020Kb
Wait-free Dynamic Transactions for Linked Data Structures Pierre LaBorde Lance Lebanof Christina Peterson University of Central Florida University of Central Florida University of Central Florida Orlando, USA Orlando, USA Orlando, USA [email protected] [email protected] [email protected] Deli Zhang Damian Dechev University of Central Florida University of Central Florida Orlando, USA Orlando, USA [email protected] [email protected] Abstract ACM Reference Format: Transactional data structures support threads executing a Pierre LaBorde, Lance Lebanof, Christina Peterson, Deli Zhang, sequence of operations atomically. Dynamic transactions and Damian Dechev. 2019. Wait-free Dynamic Transactions for Linked Data Structures. In allow operands to be generated on the fy and allows threads The 10th International Workshop on Pro- to execute code in between the operations of a transaction, gramming Models and Applications for Multicores and Manycores (PMAM’19 ), February 17, 2019, Washington, DC, USA. ACM, New in contrast to static transactions which need to know the York, NY, USA, 10 pages. htps://doi.org/10.1145/3303084.3309491 operands in advance. A framework called Lock-free Transac- tional Transformation (LFTT) allows data structures to run high-performance transactions, but it only supports static 1 Introduction transactions. We extend LFTT to add support for dynamic The rise of multi-core systems has led to the development transactions and wait-free progress while retaining its speed. of highly concurrent non-blocking data structures [7, 19, The thread-helping scheme of LFTT presents a unique chal- 20, 29]. Traditionally, non-blocking data structures provide lenge to dynamic transactions. We overcome this challenge operations which meet the linearizability correctness con- by changing the input of LFTT from a list of operations to dition. Linearizable operations appear to execute instanta- a function, forcing helping threads to always start at the neously, and respect the real-time ordering of operations. beginning of the transaction, and allowing threads to skip Lock-freedom and wait-freedom are two diferent kinds of completed operations through the use of a list of return non-blocking algorithms that guarantee at least one or all values. We thoroughly evaluate the performance impact of threads make progress in a fnite amount of time, respec- support for dynamic transactions and wait-free progress and tively. These algorithms are free from common pitfalls as- fnd that these features do not hurt the performance of LFTT sociated with locking such as deadlock, livelock, and prior- for our test cases. ity inversion, by defnition. Wait-free algorithms are also starvation-free, by defnition. A limitation of non-blocking containers is a lack of support CCS Concepts • Computing methodologies → Shared for composite operations, which precludes modular design memory algorithms; Concurrent algorithms. and software reuse. For example, inserting an element into Keywords Transactional Data Structures, Wait-Free, Trans- a lock-free linked list, and incrementing a separate variable actional Memory, Non-blocking that stores the length of the linked list is not possible without breaking linearizability, as most non-blocking data structures can only guarantee atomic updates to a single memory word. The aforementioned composite operation could fail if two Permission to make digital or hard copies of all or part of this work for threads concurrently insert elements at non-adjacent posi- personal or classroom use is granted without fee provided that copies are not made or distributed for proft or commercial advantage and that copies bear tions in the linked list, concurrently read the size variable this notice and the full citation on the frst page. Copyrights for components as ten, and then write the new value which they will both of this work owned by others than ACM must be honored. Abstracting with compute as eleven. The trade-of between correctness and credit is permitted. To copy otherwise, or republish, to post on servers or to support for composite operations in non-blocking data struc- redistribute to lists, requires prior specifc permission and/or a fee. Request tures does not need to be made if the data structures are permissions from [email protected]. made transactional. PMAM’19 , February 17, 2019, Washington, DC, USA © 2019 Association for Computing Machinery. Implementing transactional containers has been the sub- ACM ISBN 978-1-4503-6290-0/19/02...$15.00 ject of several recent papers [2, 9, 10, 13, 14, 18]. Transac- htps://doi.org/10.1145/3303084.3309491 tional execution is essential for applications that require PMAM’19 , February 17, 2019, Washington, DC, USA LaBorde, et al. atomicity and isolation for a series of operations such as i f (!list.find(key)) { databases and data analysis applications. In this paper, we r e s u l t = . // some computation discuss data structure transactions, which are sequences of list.insert(result); } operations that are executed atomically, in isolation, on a shared memory data structure. Isolation means concurrent transaction executions appear to take efect in some sequen- tial order. In this paper, we present Dynamic Transactional Trans- The straightforward way to implement a transactional formation (DTT), a framework that builds upon LFTT to data structure from a sequential container is to use soft- increase its applicability; namely, to add support for (1) dy- ware transactional memory (STM) [26]. An STM instruments namic transactions, (2) wait-free progress, and (3) transac- memory accesses by recording the locations a thread reads tions among multiple data structures. First, dynamic transac- allow operands to be generated during the transaction, in a read set, and the locations it writes in a write set. If the tions read/write sets of diferent transactions overlap, only one and threads can execute code between the operations of a transaction is allowed to commit, the concurrent transactions transaction. In contrast to other transactional methodologies, are aborted and restarted. A drawback of STM is that the run- LFTT presents a nontrivial challenge to support dynamic time system that keeps track of read/write sets and detects transactions due to its thread-helping scheme. To address conficts can have a detrimental impact on performance [3]. this issue, we require that the user writes a function that The inherent disadvantage of STM concurrency control encompasses all of the operations to be performed in the is that transaction as well as any code that the user wants to run low-level memory access conficts do not necessarily between the operations. To maintain correctness in the pres- correspond to high-level semantic conficts. Consider a set im- plemented as an ordered linked list, where each node has ence of this code between operations, we modify the helping two felds, an integer value and a pointer to the next node. scheme so that helping threads always start at the beginning of the transaction. Then to reduce duplicate work, we main- The initial state of the set is f0; 3; 6; 9; 10g. Thread 1 and Thread 2 intend to insert 4 and 1, respectively. Since these tain a list that contains the return value for each operation two operations commute, it is feasible to execute them con- in the transaction, which allows helping threads to skip com- currently [4]. Commutative data structure operations are pleted operations. Second, we support wait-free progress those which have no dependencies on each other; reordering by employing the fast-path-slow-path technique [17]. Third, them yields the same abstract state of the container. Existing transactions among multiple data structures can be simply concurrent linked lists employing lock-free or fne-grained implemented by modifying a structure in LFTT representing locking synchronizations allow concurrent execution of the an operation, to add a feld that references the container on two operations. Nevertheless, these operations have a read- which to operate. /write confict and the STM has to abort one of them. Like LFTT, our approach is applicable to the class of linked An alternative approach called Lock-free Transactional data structures that implement the set and dictionary abstract Transformation (LFTT) [30] includes semantic confict de- data types. We apply DTT to create dynamic transactional tection that uses information about the data structures and versions of a linked list [12], a skip list [8], an MDList [28], which operations are being executed, to prevent conficting a dictionary [29], and a binary search tree [16]. Lock-free operations from unnecessarily causing transactions to abort. transactional versions of the linked list and skip list were A signifcant advantage of using data structure transactions presented as a proof of concept for LFTT in [30]. is that this semantic information is available to be used to We analyze the impact of these new features on the per- increase throughput. formance of LFTT. Our evaluation shows that DTT performs The main drawback of using LFTT is that it only supports on par with LFTT, while providing the benefts of dynamic transaction support, a stronger progress guarantee, and trans- static transactions—it requires all operations to declare their operands in advance, and a thread cannot execute any code actions among multiple containers. There is less than a 1% between the operations of a transaction. LFTT needs a static diference when averaged over all tested scenarios, and like list of operations and operands before the transaction begins, LFTT, our approach is 3 times faster than STM. because it has threads help each other complete pending This paper makes the following contributions: operations before starting new ones; this is how LFTT guar- antees system-wide progress. This limitation restricts the • We present DTT, an extension to LFTT to provide sup- applicability of LFTT to small applications whose inputs are port for dynamic data structure transactions, which known in advance. For example, the following code snip- allow code to be run between data structure opera- pet could not be executed by LFTT.