Hostname: page-component-74656f9884-skzmx Total loading time: 0 Render date: 2026-11-06T08:57:52.248Z Has data issue: false hasContentIssue false

Locksynth: Deriving Synchronization Code for Concurrent Data Structures with ASP

Published online by Cambridge University Press:  01 September 2023

SARAT CHANDRA VARANASI
Affiliation:
General Electric Research, NY, USA (e-mail: saratchandra.varanasi@ge.com)
NEERAJ MITTAL
Affiliation:
The University of Texas at Dallas, Richardson, TX 75080, USA (e-mails: neerajm@utdallas.edu, gupta@utdallas.edu)
GOPAL GUPTA
Affiliation:
The University of Texas at Dallas, Richardson, TX 75080, USA (e-mails: neerajm@utdallas.edu, gupta@utdallas.edu)
Rights & Permissions [Opens in a new window]

Abstract

We present Locksynth, a tool that automatically derives synchronization needed for destructive updates to concurrent data structures that involve a constant number of shared heap memory write operations. Locksynth serves as the implementation of our prior work on deriving abstract synchronization code. Designing concurrent data structures involves inferring correct synchronization code starting with a prior understanding of the sequential data structure’s operations. Further, an understanding of shared memory model and the synchronization primitives is also required. The reasoning involved transforming a sequential data structure into its concurrent version can be performed using Answer Set Programming, and we mechanized our approach in previous work. The reasoning involves deduction and abduction that can be succinctly modeled in ASP. We assume that the abstract sequential code of the data structure’s operations is provided, alongside axioms that describe concurrent behavior. This information is used to automatically derive concurrent code for that data structure, such as dictionary operations for linked lists and binary search trees that involve a constant number of destructive update operations. We also are able to infer the correct set of locks (but not code synthesis) for external height-balanced binary search trees that involve left/right tree rotations. Locksynth performs the analyses required to infer correct sets of locks and as a final step, also derives the C++ synchronization code for the synthesized data structures. We also provide a performance analysis of the C++ code synthesized by Locksynth with the hand-crafted versions available from the Synchrobench microbenchmark suite. To the best of our knowledge, our tool is the first to employ ASP as a backend reasoner to perform concurrent data structure synthesis.

Information

Type
Original Article
Copyright
© The Author(s), 2023. Published by Cambridge University Press
Figure 0

Algorithm 1 Algorithm to Generate Synchronization Code for Operation $\sigma_i$

Figure 1

Listing 1: Synchronization code generated for operation $\sigma_i$.

Figure 2

Listing 2: Sample Background Data Structure Theory.

Figure 3

Listing 3: Sample Sequential Data Structure Knowledge.

Figure 4

Listing 4: Maximally Applicable instance viewed as Constraint Satisfaction.

Figure 5

Table 1: Synthesis procedure (left) & Prolog bindings for linked list insert (right)

Figure 6

Listing 5: Rules that consider all possible concurrent interactions.

Figure 7

Listing 6: Background theory projected into temporal domain.

Figure 8

Listing 7: Program Order Checking.

Figure 9

Listing 8: Checking lock adequacy.

Figure 10

Table 2: Code with annotations (left) and sequential code for External BST (right)

Figure 11

Listing 9: Mapping of l-values and r-values.

Figure 12

Table 3: Prolog code within Locksynth to infer l-values and r-values

Figure 13

Listing 10: Preconditon validation logic captured as validate/4 facts.

Figure 14

Listing 11: Generated Code for an Insert Operation Basic Block.

Figure 15

Fig. 1. Comparison of effective update ratios of synthesized data structures under mixed (MW) and write-dominated (WD) workloads for different key space sizes.

Figure 16

Table 4. Locksynth results on linked lists and (external) binary search trees