Optimal dynamic partial order reduction with context-sensitive independence and observers
산업용 섬유 · (8) HDPE 섬유(FORPE)
기본 정보
- 저자
- DOI
- 10.1016/j.jss.2023.111730
- 저널
- Journal of Systems and Software
- 발행년도
- 2023
- 발행기관
- Elsevier BV
- 피인용수
- 2
- 라이선스
- cc-by-nc-nd
- 논문 유형
- –
- 언어
- –
- 원문 페이지
- https://doi.org/10.1016/j.jss.2023.111730
- 토픽
- Fuel Cells and Related Materials
- OpenAlex ID
- W4367301512
평가 내용
- 관련도
- 사업분야
- 산업용 섬유 · (8) HDPE 섬유(FORPE)
- 부 분야
- –
- R&D 측면
- –
- 확신도
- –
- 근거 용어
- –
- 판단 근거
- 임베딩 유사도 기반 평가로 '산업용 섬유 > HDPE 섬유(FORPE)' 분야에 선정된 논문입니다.
- R&D 활용 포인트
- –
- 평가 입력
- –
초록
본문 156,189자
본문 펼치기
섹션 본문 204문단 · 95,507자
(제목 없음)
1Dynamic Partial Order Reduction (DPOR) algorithms are used in stateless model checking of concurrent programs to avoid the exploration of equivalent execution sequences.In order to detect equivalence, DPOR relies on the notion of independence between execution steps.As this notion must be approximated, it can lose precision and thus treat execution steps as interfering when they are not.Our work is inspired by recent progress in the area that has introduced more accurate ways to exploit conditional notions of independence: Context-Sensitive DPOR considers two steps p and t independent in the current state if the states obtained by executing p • t and t • p are the same; Optimal DPOR with Observers makes their dependency conditional to the existence of future events that observe their operations.This article introduces a new algorithm, Optimal Context-Sensitive DPOR with Observers, that combines these two notions of conditional independence, and goes beyond them by exploiting their synergies.The implementation of our algorithm has been undertaken within the Nidhugg model checking tool.Our experimental evaluation, using benchmarks from the previous works, shows that our algorithm is able to effectively combine the benefits of both context-sensitive and observers-based independence and that it can produce exponential reductions over both of them.
Introduction
2A fundamental challenge in the verification and testing of concurrent programs arises from the combinatorial explosion that results from exploring the different ways in which processes/threads can interleave.There are several proposals to reduce the number of explored interleavings, such as depth-and context-bounding [25].Among all proposals, Dynamic Partial Order reduction (DPOR) stands out due to its proven scalability, which results from being a stateless approach, i.e., one where global states do not need to be explicitly stored.DPOR is the dynamic realization of Partial-Order Reduction (POR) [14,15,12].POR is a general theory that provides full coverage of all possible executions of concurrent programs by identifying equivalence classes of redundant executions, and only exploring one representative of each class.POR considers two execution sequences equivalent if one can be obtained from the other by swapping adjacent, independent execution steps.Each such equivalence class is called a Mazurkiewicz [24] trace, and POR guarantees that exploring one sequence per equivalence class is sufficient to cover all.Early POR algorithms [15,12,31] re-lied on static approximations of independence.The Dynamic-POR (DPOR) algorithm [13] was a breakthrough because it uses the information witnessed during the actual execution of the sequence to decide dynamically what to explore.Thus, it often explores less sequences than approaches based on static approximations.As a result, DPOR is considered one of the most scalable techniques for software verification.
3The cornerstone of DPOR is the notion of (in)dependence, which is used to decide if two concurrent execution steps p and t (do not) interfere with each other and, thus, both sequences p followed by t (written p.t) and the reversed t.p must (not) be explored.To guarantee soundness, DPOR approximates independence and, thus, can lose precision if it treats execution steps as interfering when they are not.Optimal DPOR (ODPOR) [1] ensures optimality, that is, only one sequence per equivalence class is explored and the exploration of any equivalent execution sequence is not even initiated.However, this is done w.r.t. a restricted notion of independence, which usually requires execution steps to be independent in any possible state during the current execution.In practice, syntactic approximations are used to detect independence: typically, two execution steps are considered dependent if both access the same variable and at least one modifies it.
4Any DPOR algorithm can thus improve its efficiency by using a more accurate independence notion [16].Two recent approaches -DPOR cs (Context-Sensitive DPOR) [4] and ODPOR ob (Optimal-DPOR with Observers) [9] -have achieved this by integrating orthogonal notions of conditional independence into DPOR:
5• DPOR cs introduced the notion of context-sensitive independence, which only requires execution steps p and t be independent in the state s where they appear.This is determined by executing sequences p.t and t.p in s, and checking if the two states reached are equal.Let us consider the following simple example, borrowed from [9], with three concurrent processes p, q and r (each containing a single instruction) where the global variable x is initialized to 0: int x = 0; process p: x = 1; process q: x = 2; process r: assert (x < 3);
6Assume p is scheduled first and we reach a state s where x==1.Executing either q.r or r.q from s yields the same final state: x==2 and the assertion holds.Thus, DPOR cs considers r and q independent in s (e.g., in x==1).
7• ODPOR ob introduced the notion of observability, where dependencies between execution steps p and t are conditional to the existence of future steps, called observers, which read the values modified by p and t.Consider again the three concurrent processes p, q and r above.Assume r is scheduled first reaching a state s where x==0 and the assertion holds.ODPOR ob considers q and p independent in s since, while their interleaved execution leads to different final states, variable x is not observed later.
Summary of Contributions
8DPOR cs and ODPOR ob modified the DPOR algorithm to exploit their notions of independence.As our overall contribution, we present a further modification of DPOR, called Optimal Context-Sensitive DPOR with Observers (ODPOR ob cs ), that not only combines and exploits these two powerful notions, but also takes advantage of their synergy to gain further pruning.Let us consider again the same three processes and the trace p.q.r.DPOR cs does not consider p and q independent in this trace, as they give different values to variable x.ODPOR ob does not consider them independent either, as r observes the different values they give to x.However, ODPOR ob cs does consider them as independent in this trace, as the assertion of observer r evaluates to true after executing either p.q or q.p.The following major contributions are needed for this:
91. Optimal Context-Sensitive DPOR.DPOR cs was originally formulated in [4] over Source-DPOR [1].Thus, it did not include the extension of wakeup trees used by ODPOR to ensure optimality, and later used to handle observers.Our first contribution is the formulation of DPOR cs over ODPOR, which we name Optimal Context-Sensitive DPOR (ODPOR cs ). 2. Extending 1 with observers.Our second contribution is to integrate observability into ODPOR cs , obtaining ODPOR ob cs .For this, we modify context-sensitive independence to be modulo observability, which only requires equivalence for variables affected by future observers.
103. Implementation and experiments.We have implemented ODPOR ob cs , DPOR cs and ODPOR cs within the Nidhugg model checking tool [23] and performed an experimental evaluation with benchmarks from [4] and [9].Our experimental results show that ODPOR ob cs can produce exponential reductions over both DPOR cs and ODPOR ob , and that, in the worst cases, it scales similarly as the best of the other systems for the considered benchmark.This article revises and extends a previous conference paper published in the proceedings of ISSTA'19 [5].In addition to fixing some errors, extending the explanations and intuitions, discussing the most recent related work and adding new and more detailed examples, we have important improvements both on the practical and theoretical sides of the work.On the practical one, rather than using our implementations within the SYCO tool [6], we have reimplemented the ODPOR ob cs , DPOR cs and ODPOR cs algorithms within their Nidhugg model checking tool [23].This very significant effort was necessary to facilitate the comparison with algorithms other than ours, particularly ODPOR [1] and ODPOR ob [9].We then performed a new and more detailed experimental evaluation using some of the original benchmarks of [9] and new encodings of those of [4].This also required implementing the necessary support to handle atomic blocks, which are needed to encode the actors based concurrency of the benchmarks in [4].On the theoretical side, we have made three major improvements.First, we have added correctness proofs of both the ODPOR cs and ODPOR ob cs algorithms.Second, we have proposed a refined and more efficient context-sensitive check that can be exploited not only in ODPOR cs and ODPOR ob cs , but also in the original DPOR cs of [4].And third, we have developed a simpler and more accurate definition of the notion of equivalence modulo observability which is key in ODPOR ob cs .
Structure of the Article
11The rest of the article is organized as follows.Section 2 introduces the technical notation and recalls background knowledge on the DPOR and ODPOR formalisms.Section 3 first describes the original DPOR cs approach and then introduces the modifications and extensions needed to define ODPOR cs , as well as the associated proofs of soundness and optimality.Section 4 presents ODPOR ob cs : the integration of observability into ODPOR cs .The results of our implementation and experimental evaluation are reported in Section 5. Finally, Section 6 discusses related work and our final conclusions.
Basics of DPOR
12As previous work on DPOR, we assume the state space does not contain cycles, executions have finite unbounded length and processes are deterministic (i.e., at a given time there is at most one event a process can execute).An execution sequence E is a finite sequence of execution steps of the system processes that is performed from the initial state.We denote by s [E] the, uniquely defined, state after executing sequence E. We use ϵ to denote the empty sequence and .to denote concatenation of sequences of process steps.E.g., p.p.q denotes the execution sequence where first p performs two steps, followed by a step of q.An event p i of execution sequence E represents the i-th occurrence of process p in E, e.g., event p 2 denotes the second execution step of process p in the previous sequence.
13Running Example.Let us consider an extension of the example in Section 1.The program contains two global variables x and y which are initialized to 0, and three processes, p, q and r.Process p contains two assignments over variables y and x respectively.Process q only includes an assignment over variable x.Finally, process r includes two assertions that check if variable x is less than 3 and 2, respectively.Int x = 0; Int y = 0; process p : process q : process r : y = 1; x = 2; assert x < 3;
14x = 1; assert x < 2;
15In this example the first assert always holds, while the second can either hold or not depending on whether x has been assigned to 2 when r 2 executes.For instance, given execution sequence E 1 = q.p.p.r.r, both asserts hold in s
16. This is also the case for sequence E 2 = p.p.r.r.q, even though we have
17In contrast, for sequence E 3 = p.p.q.r.r, the second assert does not hold since process q writes 2 over variable x before process r reads it.
18We use e < E e ′ to denote that event e occurs before event e ′ in sequence E, s.t.< E establishes a total order between events in E. The core concept in DPOR is that of the happens-before partial order among the events in execution sequence E, denoted by → E .This relation is used to define a subset of the < E total order, such that any two sequences with the same happens-before order are equivalent.Let dom(E) denote the set of events in E.
19Any linearization E ′ of → E on dom(E) is an execution sequence with the same happens-before relation → E ′ as → E .Thus, → E induces a set of equivalent execution sequences, all with the same happens-before relation.We use E ≃ E ′ to denote that E and E ′ are equivalent.DPOR algorithms use this relation to reduce the number of equivalent execution sequences explored, with ODPOR ensuring that only one execution sequence in each equivalence class is explored.
20Example 1.Let us consider again sequence E 1 = q.p.p.r.r of our running example.Its total order of events is: q
21Its happens-before relation is as follows:
22Another possible linearization of this happens-before relation is hence E ′ 1 = p.q.p.r.r.Since both E 1 and E ′ 1 have the same happens-before relation we have
23As done in [1] to support any computation model, our approach assumes the existence of a happens-before assignment function that assigns a happens-before relation to any execution sequence.The precision of such function can vary as long as it satisfies the set of properties specified in [1].For the examples throughout the paper we assume a happens-before assignment based on the traditional approximation of dependency for programs with shared variables.Namely, two events p and q are considered dependent if either one enables the other (i.e., executing E.p introduces q, or vice versa), or if both access the same variable and at least one modifies it.
24The happens-before relation is also used for defining the notion of race.Event e is said to be in race with event e ′ in execution E, written e ⋖ E e ′ , if the events belong to different processes, e happens-before e ′ in E (e → E e ′ ), and the two events are "concurrent" (∃E ′ s.t.E ′ ≃ E and the two events are adjacent in E ′ ).This implies that there is no intermediate event e ′′ in E such that e → E e ′′ → E e ′ .We also write e ≾ E e ′ to denote that e is in a reversible race with e ′ , i.e., e is in a race with e ′ and the two can be reversed (∀E ′ s.t.E ′ ≃ E and e appears immediately before e ′ , e ′ is not blocked).These are the only races the algorithms need to dynamically check for independence.
25Example 2. In both sequences E 1 and E ′ 1 of our running example, we have q 1 ≾ E 1 p 2 , i.e., event q 1 is in a reversible race with event p 2 .This is because the events belong to different processes, they are concurrent, i.e., ∃E ′ s.t.E ′ ≃ E 1 where the two events are adjacent (namely, E ′ = p.q.p.r.r), and none of them can block the other one.
26Other notation we use includes: ê, denoting the process of event e (e.g., q1 is q in our example); enabled(s), the set of processes that can perform an execution step from state s (e.g., a locking operation can be enabled if the lock is not taken, or disabled when it is taken); and pre + (E, e), respectively pre(E, e), the prefix of sequence E up to e, including and not including e (e.g., pre + (E ′ , p 2 ) is p.q.p and pre(E ′ , p 2 ) is p.q in the previous example).
Optimal DPOR
27The code in black of Algorithm 1 (excluding underlined blue parts) corresponds to the ODPOR algorithm [1] adapted so that it does not make use of sleep-sets, as proposed in [9].ODPOR carries out a depth-first exploration of the execution tree from an (initially empty) execution sequence E. Essentially, it dynamically finds reversible races and is able to backtrack at the appropriate scheduling points to reverse them.For this purpose, it keeps two sets for every sequence E explored: the wakeup tree of E containing the execution sequences that must be explored from E, and the set of processes that are done from E, that is, have already been explored from it.
28Wakeup Trees.A wakeup tree is an ordered tree ⟨B, ≺ ⟩, where the set of nodes B is a finite prefix-closed set of sequences of processes, with the empty sequence ϵ at the root.The children of node w are ordered by ≺ and have the form w.p for some set of processes p.We write wut(E) to denote the wakeup tree of sequence E. Intuitively, wut(E) is composed of partial execution sequences that must be explored from E, as they (a) reverse the order of detected races, and (b) are not provably equivalent.
29The algorithm makes use of the following functions over wakeup trees:
30• insert [E] (v, wut(E)) returns the extension of wut(E) with a new sequence v.
31• subtree(⟨B, ≺ ⟩, p) returns the subtree of wakeup tree ⟨B, ≺ ⟩ rooted at process p ∈ B, i.e., the tree ⟨B ′ , ≺ ′ ⟩, where B ′ = {w|p.w∈ B} and ≺ ′ is the restriction of ≺ to B ′ .
32Algorithm 1 ODPOR cs algorithm dnd(E) := DnD; wut(E) := WuT ; 7:
33for each p ∈ dnd(E) such that |p| = 1 :
34RaceDetection(E.p); wut(E) := ⟨{ϵ, p}, {(p, ϵ)}⟩;
3513:
36while ∃p ∈ wut(E) do 14:
37if p ∈ dnd(E) then 16:
38RaceDetection(E.p); let WuT ′ = subtree(wut(E), p);
39∪ {v | (p.v) ∈ dnd(E)};
21:
40Explore(E.p,WuT ′ , DnD ′ );
22:
41add p to done(E);
23:
42remove all sequences of form p.w from wut(E);
4324: procedure RaceDetection(E)
25:
44for all e, e ′ ∈ dom(E) such that e ≾ E e ′ do 26:
45let E ′ = pre(E, e); let dont = ϵ;
4627:
47] then
29:
48dont := v.ê;
49add dont to dnd(E ′ );
50ODPOR starts by selecting (line 14) the leftmost process p in the wakeup tree, according to its order ≺, that is enabled by state s [E] (due to line 4).If there is such a process, it sets WuT ′ as the subtree of wut(E) with root p (line 18), and recursively explores every sequence in WuT ′ from E.p (line 21).Note that wut(E) might grow as this recursion progresses, due to later executions of line 31.After the recursion finishes, it adds p to done(E), removes from wut(E) all sequences that start with p, and iterates selecting a new p.Once a complete sequence E has been explored (E is said to be complete if enabled(s [E] ) = ∅), the algorithm performs the race detection phase (line 4).This starts by finding all pairs of events e and e ′ in dom(E) such that e ≾ E e ′ , that is, e is in a reversible race with e ′ .For each such pair, it sets E ′ to pre(E, e) and v to notdep * (e, e ′ , E). ê′ (line 27), where notdep * (e, e ′ , E)1 is the subsequence of processes ê′′ of E such that e < E e ′′ and e ↛ E e ′′ , that is, e occurs before e ′′ in E but does not happen-before it.Let us explain the intuition of this construction.In order to reverse the race, we need to explore a sequence in which e ′ is executed before e without changing any other happens-before relation.Such sequence must start by E ′ .v.e ′ where v includes all events that are dependent with e ′ .In order to ensure optimality, v might also need to include other events.The sequence computed by notdep * includes all events that are independent with e and, therefore, all events that are dependent with e ′ (otherwise there would be no race) and also those that might be needed to ensure optimality.That is, it includes those events that are necessary and possibly more.Later, notdep * will be refined to include the shortest sequence that is needed.
51Finally, if the exploration of v in E ′ is not redundant w.r.t already explored sequences (line 30), i.e., it does not lead to equivalent explorations, it is inserted into wut(E ′ ) (line 31).Redundancy is detected by means of the so called weak initials sets [1].The weak initials set of sequence w from execution E, denoted WI [E] (w), contains any process (in w or not) with no happens-before predecessors in dom [E] (w), where dom [E] (w) denotes the subset of events in execution sequence E.w that are in w, i.e., dom(E.w)\dom(E).
52Example 3. In our running example, the set dom [q.p] (p.r.r) contains the events executed by sequence p.r.r after executing q.p, that is, {p 2 , r 1 , r 2 }.The weak initials set WI [ϵ] (q.p.p.r.r) contains q since it does not have happens-before predecessors in {p 2 , r 1 , r 2 }; and p since p 1 does not have happens-before predecessors in {p 2 , r 1 , r 2 } either (as can be seen in Example 1).
53The redundancy check of line 30 is then defined as follows: v ∈ redundant(E ′ , done) iff E ′ .v is an execution sequence and there is a partitioning E ′ = w.w′ such that done(w) ∩ WI [w] (w ′ .v)∅.Intuitively, this check determines if the algorithm has already explored a subsequence that is equivalent to E ′ .v,by succeeding if a process without happens-before predecessors in the subset of events of E ′ .vthat are in w ′ .v,has already been explored (done) from sequence w.This is shown in action later in Example 4 (in the RaceDetection at state 15).
54Note that in the original ODPOR algorithm [1] this check is implemented using sleep-sets.However, [9] shows that sleepsets are not suitable as a mechanism to avoid redundant exploration in the presence of observers, and proposes this alternative definition that, as we have seen, relies on the done and weakinitials sets.We have therefore adopted this solution to ensure the ODPOR algorithm is ready for the integration of observers.
55Example 4. The execution tree that ODPOR explores for the running example is shown in Figure 1.Each node in the tree
State Cause
56Effects 5 p 2 ≾ E r 1 (access to x) r added to wut(q.p) 5 q 1 ≾ E p 2 (write to x) p.p added to wut(ϵ) 8 p 2 ≾ E r 2 (access to x) r added to wut(q.p.r) 8 q 1 ≾ E r 1 (access to x) p.r added to wut(ϵ) 15 q 1 ≾ E r 1 (access to x) r added to wut(p.p) 15 p 2 ≾ E q 1 (write to x) q not added to wut(p) 18 q 1 ≾ E r 2 (access to x) r added to wut(p.p.r) 18 p 2 ≾ E r 1 (access to x) r added to wut(p) 24 q 1 ≾ E r 2 (access to x) r added to wut(p.r.p) 24 p 2 ≾ E q 1 (write to x) q added to wut(p.r) 26 p 2 ≾ E r 2 (access to x) r added to wut(p.r)29 p 2 ≾ E r 2 (access to x) r added to wut(p.r.q) 34 p 2 ≾ E q 1 (write to x) q added to wut(p.r.r) wut(ϵ) = ⟨{ϵ, q, p, p.p, p.r}, {(q, p.p), (p.p, p.r)}⟩ q ϵ p.p p p.r corresponds to a different call to Explore.The meaning of the different labels is explained in the figure caption.The lower node labels (in blue) and the boxes labeled P1-P6 should be ignored for now.They correspond, respectively, to don't-do sets (see Section 3.1), and to prunings that the other algorithms per-form.Figure 2 lists the main actions that are carried out by the algorithm showing, for each of them, the state, the cause (i.e. the reversible race) and the effects of the action (i.e. the updates on wakeup trees).
57ODPOR starts with both E and WuT empty (state 0).Let us assume the algorithm first explores sequence q.p.p.r.r (by picking respectively these processes in each recursive call in line 11), thus reaching state 5 and invoking RaceDetection (line 4).Since the happens-before relation of this explored execution is the one shown in Example 1, a reversible race between p 2 and r 1 is detected (p 2 happens-before r 1 , appears immediately before r 1 and does not block it) setting E ′ to q.p and v to r.This causes the addition of r to wut(q.p)(see upper label of state 2), indicating the algorithm will eventually have to backtrack to state 2 to explore process r.A reversible race between q 1 and p 2 is also detected, setting E ′ to ϵ and v to p.p (line 27), thus adding p.p to wut(ϵ) (upper label of state 0).The algorithm then backtracks to state 2 (the first one with nonempty wut), along the way adding r to the done sets of states 4 and 3, and p to the done set of state 2 (line 22).Then it explores q.p.r (as determined by its wut, which has r) reaching state 6.Let's assume it then explores q.p.r.p.r thus reaching state 8 and invoking RaceDetection.Two reversible races are detected: one between r 2 and p 2 , which causes the addition of r to wut(q.p.r) (upper label of state 6), and one between r 1 and q 1 , which causes the addition of p.r to wut(ϵ) (upper label of state 0).The algorithm then backtracks to state 6 whose non-empty wut has r (adding the appropriate processes to the done sets), explores q.p.r.r.p and invokes RaceDetection at state 10, which detects no new races.Figure 3 shows the wut(ϵ) at this point, both in textual and graphical forms.Node q will be deleted from it when backtracking to state 0 and hence sequences p.p and p.r remain to be explored.
58The algorithm now backtracks to state 0 (removing r from the wut of states 6 and 2 on the way due to line 23, and appropriately updating the done sets as before) whose wut has both p.p and p.r.Let us assume p.p is explored first, reaching p.p.q.r.r (at state 15) and invoking RaceDetection.It detects two reversible races: one between r 1 and q 1 , which causes the addition of r to wut(p.p)(state 12), and one between q 1 and p 2 .In this latter case q is not added to wut(p) (state 11) because we have q ∈ redundant(p, done) (line 30), which means the exploration that would be performed from p.q is redundant to that already performed from q.p.Applying the above definition of redundant, E ′ .v, in this case let E ′ = p and v = q, is an execution sequence and there is a partitioning E ′ = w.w′ , in this case let w = ϵ and w ′ = p, such that we have a non-empty intersection between done(ϵ) = {q} and WI [ϵ] (p.q) = {p, q}.
59The algorithm then backtracks to state 12 (updating the wut and done sets of intermediate states as usual) whose wut has r, and explores p.p.r.q.r reaching state 18.The invocation to RaceDetection detects two reversible races: one between r 2 and q 1 , which causes the addition of r to wut(p.p.r) (and the subsequent exploration of sequence p.p.r.r.q), and one between r 1 and p 2 , which causes the addition of r to wut(p) (though this has no effect since r is already inherited down to wut(p) from wut(ϵ)).The algorithm then backtracks to state 11 whose wut now only has r and explores the subtree rooted at state 21.Let us just list the reversible races that are responsible for updating the wakeup trees of states 21, 22 and 27: At state 24 two reversible races are detected: one between r 2 and q 1 , which causes the addition of r to wut(p.r.p), and one between q 1 and p 2 , which causes the addition of q to wut(p.r).At state 26 the reversible race between r 2 and p 2 causes the addition of r to wut(p.r).At state 29 the reversible race between r 2 and p 2 causes the addition of r to wut(p.r.q).Finally, at state 34 the reversible race between q 1 and p 2 causes the addition of q to wut(p.r.r).
60Overall, ODPOR has explored 12 executions that matches the 12 possible happens-before relations corresponding to all ordering combinations of events q, p 2 , r 1 and r 2 , with the restriction that r 1 cannot go after r 2 .A full systematic exploration would have to explore 30 executions.Note also that ODPOR has not even had to initiate any redundant exploration.Instead, the original DPOR algorithm very often needs to explore partial executions before noticing they lead to redundant explorations (the so called sleep-set-blocked explorations).
Context-Sensitive DPOR
61The first algorithm that has used notions of conditional independence within the state of the art DPOR algorithm is Context-Sensitive DPOR [4] (DPOR cs ).This algorithm exploits contextsensitive independence, which requires checking the commutativity in the current state (the context) of every two events that are in race.If they commute, the algorithm prevents the exploration of the reversed race by adding information to the sleep set.DPOR cs was built in [4] on top of Source-DPOR [1] and includes the following two main features:
62• Sleep-set extension.Sequences of processes are more expressive than single processes, thus sleep sets are generalized to contain sequences of processes.We denote this new kind of set as the don't-do set.Sequences in the don'tdo sets are ignored, as they are proven to lead to redundant exploration thanks to context-sensitive independence.
63• State equivalence check.When a reversible race e ≾ E e ′ is detected, in addition to recording the required information to ensure the race is reversed on backtracking, the algorithm also checks whether events e and e ′ are independent in the current context E, that is, whether
64If so, the corresponding don't-do set is extended with the sequence of the reversed race to avoid its exploration.
65Example 5. Let us consider the exploration of sequence q.p.p.r.r in the example of Figure 1.When DPOR cs reaches state 4, it realizes p 2 and r 1 can be regarded as independent in context q.p, as s [q.p.p.r] = s [q.p.r.p] , even though they are dependent according to the happens-before relation in [1] with the usual syntactic approximation, since p 2 writes global variable x and r 1 reads it.Hence, it adds r.p to the don't-do set of state 2 (see its lower label, which is shown in negative form, i.e., ¬r.p).
66Once r is explored, p is not executed because it is in the don'tdo set of state 6 (don't-do sets are propagated downwards in the tree by eliminating the explored process -in this case rfrom the sequence -in this case from r.p), which prevents the full exploration of q.p.r.p.r.
67As mentioned before, our first contribution is the reformulation of DPOR cs as an extension of ODPOR, rather than of Source-DPOR.This yields an optimal DPOR cs algorithm (see below), referred to as ODPOR cs , which enables the integration of the notion of observers (as done in Section 4).Reformulating DPOR cs in terms of ODPOR is challenging due to two main problems:
68• Challenge I: While Source-DPOR performs race detection at every state, ODPOR must delay race detections until the sequence being explored is complete.
69• Challenge II: As shown in [4], the effectiveness of DPOR cs is highly dependent on exploring don't-do sequences as soon as possible.Indeed, DPOR cs uses these sequences to guide the selection of the next process to be explored.However, the wakeup trees of ODPOR fix part of these decisions, which can affect guidance.
70The ODPOR cs algorithm corresponds to the full code of Algorithm 1 (both black and underlined in blue).The algorithm is discussed in detail in Sections 3.2 and 3.3, which explain how challenges I and II, respectively, have been faced.In addition, Section 3.4 proposes a refinement to the context-sensitive check of both ODPOR cs and DPOR cs that makes it potentially much more efficient in certain cases.The proofs of correctness and optimality for ODPOR cs are provided in Appendix A.
Challenge I
71Delaying race detections until the entire sequence is explored, complicates the implementation of the context-sensitive checks, as they need access to intermediate states.One could recover these states by, for example, re-executing the sequence of events to reach them, or storing them, either in full or by means of incremental state updates, to be undone on backtracking.One could also perform (part of) the checks on the fly during the exploration, instead of at the end, thus reducing the number of intermediate states needed.The preferred strategy will depend on the available memory and the concrete language features.In any case, the following assumes access to all states of the current sequence.
72The new context-sensitive check corresponds to the underlined blue code in line 28 of Algorithm 1 (for now, we use the black code for v in line 27; it will be redefined in Section 3.3).Recall that the black code of Algorithm 1 is common to both ODPOR and ODPOR ob , and was described in Section 2.2.Intuitively, given a reversible race e ≾ E e ′ for events e and e ′ , the new check succeeds if the state right after the race, s [pre + (E,e ′ )] , is the same as that obtained when the race is reversed,
73, where suc(e, E) is the subsequence w of E that starts with ê and contains all ê′′ s.t. e → E e ′′ , and w ≤ e ′ E is the subsequence of w in E of processes that execute events up to, and including, e ′ (i.e., keeps ê′′ only if e ′′ ≤ E e ′ ).As a result, the sequence E ′ .(v.suc(e, E)) ≤ e ′ E executes the same events as pre + (E, e ′ ) but with the race reversed.Assuming we have access to s [pre + (E,e)] and s [E ′ ] , we only need to compute the state after the sequence (v.suc(e,E))
74If the check succeeds and v is not redundant for E ′ , sequence v.ê is added to the don't-do set dnd(E ′ ) (line 32).Note that, unlike in the original DPOR cs , v contains the processes of events executed after e ′ in E, that do not happen-after e and, thus, neither happen-after e ′ .This issue is further discussed in Section 3.3.
75As in the original DPOR cs , if a sequence w is added to the don't-do set of state s, w can be inherited down once we backtrack to s, possibly being reduced until it eventually becomes a unitary sequence and the exploration stops (referred to as a don't-do set blocked exploration).In that case, race detection must be forced explicitly.This is the task of the new if statement in lines 15 and 16.Similarly, if every process enabled in s [E] is also in dnd(E) for sequence E, then the exploration of E stops and race detection is forced explicitly, in this case for every unitary sequence in dnd(E) (lines 7, 8 and 9).The support to inherit down don't-do sequences is the same as in the original DPOR cs , corresponding to lines 19 and 20.Essentially, E.p inherits each sequence v where p.v ∈ dnd(E) (line 20), and where every process in v (line 19) is independent of p in E (denoted as E | = p ⋄ v), i.e, where the event in dom [E] (p) does not happen-before any event in dom [E.p] (v).
St. Cause
76Effects 5 p 2 ≾ E r 1 and s [q.p.p.r] = s [q.p.r.p] r.p added to dnd(q.p) 5 q 1 ≾ E p 2 and s [q.p.p] s [p.p.q] -6 p ∈ dnd(q.p.r) ⇐ r.p ∈ dnd(q.p)Pruning P1 10 q 1 ≾ E r 1 and s [q.p.r] = s [p.r.q] p.r.q added to dnd(ϵ) 15 q 1 ≾ E r 1 and s [p.p.q.r] = s [p.p.r.q] r.q added to dnd(p.p)16 q ∈ dnd(p.p.r) ⇐ r.q ∈ dnd(p.p)Pruning P2 20 p 2 ≾ E r 1 and s [p.p.r] = s [p.r.p] r.p added to dnd(p)
77Pruning P3 21 q ∈ dnd(p.r)⇐ r.q ∈ dnd(p)
78Pruning P4 nodes that are not explored and hence are pruned by ODPOR cs .
79Sequences starting with ¬ in parenthesis should be ignored by now.In the following we explain the most relevant additional actions that ODPOR cs performs w.r.t ODPOR, some of which lead to the above-mentioned prunings.Figure 4 lists such actions, showing, for each of them, the state, the cause (i.e. the result of the context-sensitive check or the inherited sequence in the don't-do set, where ⇐ should be read as "inherited from") and the effects of the action (i.e. the updates on don't-do sets or the pruning carried out).
80In the invocation to RaceDetection at state 5, i.e., after exploring sequence q.p.p.r.r, for the race between p 2 and r 1 , the new context-sensitive check at line 28 checks if s [q.p.p.r] = s [q.p.r.p] .Since the check succeeds r.p is added to dnd(q.p)(lines 29 and 32).Also at state 5, for the race between p 2 and q 1 , ODPOR cs checks whether s [q.p.p] = s [p.p.q] , but this time the check fails and, hence, nothing is added to dnd(ϵ).
81When backtracking to state 2 with r, sequence r.p in dnd(q.p) is inherited down as p in dnd(q.p.r) (line 20).This causes the pruning of box P1.At state 6, r is chosen to be explored, because p is in dnd(q.p.r).p is then removed from dnd(q.p.r.r) in line 19 since p 2 and r 1 are dependent (i.e., we do not have q.p.r | = p ⋄ r).The algorithm fully explores sequence q.p.r.r.p and then invokes again RaceDetection at state 10.For the reversible race between q 1 and r 1 , the check s [q.p.r] = s [p.r.q] succeeds and, hence, p.r.q is added to dnd(ϵ).
82The race between r 2 and p 2 causes the addition of p to wut(q.p.r).Hence, when the algorithm backtracks to state 6, and since p is both in wut(q.p.r) and dnd(q.p.r), RaceDetection is explicitly invoked (lines 15 and 16), though this time nothing new is added to any wakeup-tree nor any don't-do set.
83ODPOR cs then fully explores sequence p.p.q.r.r and invokes RaceDetection at state 15.For the race between r 1 and q 1 the algorithm checks whether s [p.p.q.r] = s [p.p.r.q] , and since the check succeeds r.q is added to dnd(p.p).This causes the pruning of box P2.The algorithm then backtracks to state 12 with r, explores sequence p.p.r.r.q and invokes RaceDetection at state 20.For the race between r 1 and p 2 the algorithm now checks whether s [p.p.r] = s [p.r.p] , and since the check succeeds r.p is added to dnd(p) (which already had r.q in it).
84The algorithm then backtracks to state 11 with r.It inherits down r.p and r.q to state 21 as p and q respectively, hence forcing it to select process r at state 21, causing the prunings of P3 and P4.Finally, sequences p.r.r.p.q and p.r.r.q.p are explored as in ODPOR.
85Overall, ODPOR cs has explored 6 executions (instead of the 12 explored by ODPOR), plus the additional explorations that need to be computed by the new context-sensitive checks.
Challenge II
86To illustrate this challenge, let us consider the processes p and q from our running example, and the initial exploration E 1 = t.t′ .p.p.q, where t is a process defined as t : z = 1; and t ′ is another instance of the same process t.Let us assume, for now, that ODPOR cs uses the original definition of sequence v (line 27), that is, v = notdep * (e, e ′ , E). ê′ .For the reversible race between p 2 and q 1 , ODPOR cs adds q to wut(t.t′ .p).Hence, upon backtracking to t.t ′ .p, it will explore E 2 = t.t′ .p.q.p.For the reversible race between t 1 and t ′ 1 , ODPOR cs sets v to p.p.q.t ′ (since all p 1 , p 2 and q are independent of t 1 , and also of t ′ 1 ) and adds it to wut(ϵ).Also, since s [t.t ′ ] = s [t ′ .t], it adds p.p.q.t ′ .t to dnd(ϵ).Later, when backtracking to ϵ and exploring p.p.q.t ′ , sequence t ′ .t is inherited down to dnd(p.p.q), which in turn causes t to be inherited down to dnd(p.p.q.t ′ ), causing the exploration to stop and the race-detection phase to start (line 16) for p.p.q.t ′ .t.This detects a race between p 2 and q 1 , causing the exploration of t ′ .t.p.q.p, which is redundant to E 2 (as
87Such a redundant trace would not have been explored by DPOR cs .This is because DPOR cs (as well as Source-DPOR and the original DPOR) does not record the sequence to be explored upon backtracking but, rather, an initial event to explore plus the sequences that should not be selected (by means of the so called backtrack-set and sleep-set).This allows using don't-do sequences to guide DPOR cs decisions regarding what to explore, achieving earlier and more effective contextsensitive prunings.However, wakeup trees are essential for ODPOR to achieve optimality.Therefore, the challenge is to determine whether it is possible to keep optimality, while at the same time being able to exploit don't-do sequences at least as effectively as DPOR cs .
88In order to reverse race e ≾ E e ′ , it suffices to have all ancestors of e ′ before it.Let us then re-define notdep * (e, e ′ , E) as ance(e, e ′ , E), the subsequence of E containing the processes whose events occur after e and happen-before ê′ (and thus, are independent with e, since otherwise e and e ′ would not be in race).This solves the problem in the above example: for the race between t and t ′ in E 1 , the sequences added to wut(ϵ) and dnd(ϵ) would be t ′ and t ′ .t,respectively.However, it is not enough since, in order to achieve optimality, v needs to include part of the processes of E whose corresponding events are independent with the ones in v, thus being detected as redundant in line 28.Let us define the set of future initials, written I fut (E ′ , v, E), that contains any process with no "happensbefore" predecessors in dom
89such that e ′ → E e).Indeed, the future initials are also required in sequence v, so that when an exploration is stopped by a don't-do sequence (line 16), the corresponding race detection phase has enough information to build the appropriate sequences for each detected new race.As a result, we redefine v as notdep * (e ′ , e ′ , E). ê′ .I fut (E ′ , v, E) (line 27) with notdep * (e, e ′ , E) = ance(e, e ′ , E).In the example above, for the race between t and t ′ in E 1 , the new sequences added to wut(ϵ) and dnd(ϵ) are t ′ .pand t ′ .p.t, respectively.
A More Efficient Context-Sensitive Check
90As explained above, for any given race, the state equivalence check of ODPOR cs (and DPOR cs ) compares the state of the current execution sequence right after the race (pre + (E, e ′ )) against that of an alternative sequence that executes the same events but with the race reversed.To ensure this, such an alternative sequence includes, after the reversed race, events that are not related to the race, namely suc(e, E) ≤ e ′ E .The computation of these alternative sequences may produce an overhead on the ODPOR cs (and DPOR cs ) algorithm.Therefore, we would like to make them as efficient as possible without compromising the effectiveness of the prunings performed due to the contextsensitive checks.
91To illustrate this, let us consider the process p from our running example, a new process t defined as t : y = 1 and an initial exploration E 1 = p.p.t.For the race between p 1 and t 1 the state equivalence check compares the states for E 1 and E 2 = t.p.p and succeeds.We can observe that in E 2 the second step of p
92) is completely unrelated to the race between p 1 and t 1 but it has been added to ensure both E 1 and E 2 have the same events.Indeed, if we take it out from E 2 the check would fail, i.e. s [p.p.t] s [t.p] .However, if the check would focus only on the variables (memory addresses) which are involved in the race, in this case variable x, then the check will succeed even with the shortened sequence t.p.
93To illustrate the potential impact this improvement may have in the algorithm, let us consider a generalization of the above pattern with a process p ′ : f or(i = 0; i < n; i++) a[i] = 0; that initializes the first n elements of an array a, a process t ′ : a[0] = 0; that simply writes on the first position of the array, and the initial exploration E ′ 1 = p ′ .p′ . . . .p ′ .t′ (where all steps of process p ′ are executed before process t ′ ).For the race between p ′ 1 and t ′ 1 the state equivalence check would compare the states of E ′ 1 and E ′ 2 = t ′ .p′ .p′ . . . .p ′ and succeed.Here we can observe the potential overhead that we may have in the computation of E ′ 2 .The proposal is to take out from E ′ 2 the events that are not related to the race, hence considering instead E ′ 2 = t ′ .p′ , and make the state equivalence check focus only on variable a[0], otherwise the check would fail.
94To accomplish this, we rewrite line 27 of Algorithm 1 as:
95where suc(e, E) ≤ e ′ E has been taken out from the sequence of the right-hand side, and V e,e ′ E added on top of the equality, indicating the equality is checked on the subset of variables V e,e ′ E , which is defined as follows.Let W E (e) and W E ({e 1 , . . .e n }) denote the set of variables (memory addresses) written in execu-tion E by event e and by the set of events {e 1 , . . .e n }, respectively.Let I e E (x) be the set of variables written by event e in execution E whose written value has been affected by variable x.We use Ē to denote the alternative sequence including event e, that is, E ′ .(v)≤ e ′ E .ê,where E ′ and v are as defined in lines 26 and 27 of Algorithm 1.We define the set of variables involved in a race between e and e ′ in execution E, written V e,e ′ E , as:
96( x∈W E (e) I e ′ E (x)) ∪
97(2)
98(W E ({e, e ′ }) \ W Ē ({e, e ′ })) ∪
99(W Ē ({e, e ′ }) \ W E ({e, e ′ }))
100The first term, labeled (1), includes the variables that are written in both events.The second and third terms include, for the original and the alternative executions E and Ē respectively, the variables written by the second event in the race whose written value has been affected by a variable written in the first event of the race in the corresponding execution.Finally, the fourth and fifth terms include the variables that are written by either e or e ′ in one of the executions that are not written by e nor e ′ in the other execution.• Consider e : x = 1; and e ′ : x = 2;.Since variable x is involved in a race between e and e ′ , it should be included in V e,e ′ E .This is captured by term (1).• Consider e : x = 1; and e ′ : y = x;.In this case term
101(2) produces {y} since the value written to y depends on whether e is executed before or not.The other terms produce the empty set.We hence get V e,e ′ E = {y}.
102• Consider e : i = 1; and e ′ : v[i] = 1; with an initial state where i = 0. Term (4) produces {v[1]} whereas term (5) produces {v[0]}.The other terms produce the empty set.We hence get V e,e ′ E = {v[0], v [1]}.If we instead consider an initial state with i = 1, we would get V e,e ′ E = {} since in this case both executions write v [1] with a value that does not depend on event e.If we consider e ′ : v[i] = i; (with initial state i = 1) then term (2) would produce {v [1]} since the written value now depends on event e.
103Note that in the case of assertion statements, the result of an assertion is assumed to be written to a memory address and thus it is included in the W and I sets.For instance, consider events e : x = 1; and e ′ : assert x > 0; with execution sequence E = e.e ′ .The result of the assertion is obviously involved in the race between e and e ′ and should be included in V e,e ′ E .This is captured by term (2) since the memory address where the result of the assertion is written to is assumed to belong to I e ′ E (x).The rest of the terms produce the empty set in this case.
Correctness and Optimality
104The following theorem ensures the soundness of our ODPOR cs extension.
105Theorem 1 (Soundness of ODPOR cs ).For each Mazurkiewicz trace T defined by the happens-before relation, Explore(ϵ, ⟨{ϵ}, ∅⟩, ∅) of Algorithm 1 explores a complete execution sequence that either implements T , or reaches an identical state to one that implements T.
106The optimality of ODPOR cs with respect to the Mazurkiewicz traces based on the context-sensitive notion of independence is in general not guaranteed, since it only detects certain cases of context-sensitive independence.However, it has analogous optimality results as the ODPOR algorithm (i.e., for the Mazurkiewicz traces based on the notion of independence of [1]): if ODPOR cs explores a don't-do set blocked execution E, then ODPOR explores completely an execution with the same happens-before relation than E.
107Theorem 2 (Optimality of ODPOR cs ).Algorithm 1 never explores two complete execution sequences that are equivalent, and never initiates redundant executions.
108The proofs of the above theorems can be found in Appendix A.
Optimal Context-Sensitive DPOR with Observers
109This section presents Optimal Context-Sensitive DPOR with Observers (ODPOR ob cs ), our new DPOR algorithm that not only combines and exploits the notions of context-sensitive independence and observability, but also takes advantage of their synergy to gain further pruning.First, Section 4.1 recalls the formal notion of observability and the Optimal DPOR with Observers (ODPOR ob ) algorithm of [9].Then, Section 4.2 presents the basic ODPOR ob cs algorithm that simply joins the ODPOR ob and ODPOR cs algorithms.Sections 4.3 and 4.4 present two enhancements that exploit the combination and the synergy between the notions of context-sensitive independence and observability.Finally, Section 4.5 studies the soundness of the enhanced ODPOR ob cs algorithm.
Optimal DPOR with Observers
110The notion of observability [9] allows dependencies between execution events to be conditional to the existence of later events called observers.The typical example in the context of programs with shared variables occurs when there are two events e and e ′ that write over the same variable, but the written value is not later read or observed.In such a case the idea is not to consider the two events as interfering and, hence, e does not happen-before e ′ .The intuition behind this approach is that only operations that observe a value (e.g.assertions or receives) can influence the control flow and lead to erroneous or unexpected behaviors, whereas other operations (e.g., writes or sends) cannot affect program behaviour if no future operation observes their effects.
111Again, as in [1], in order not to restrict to any specific computation model, Aronis et.al. [9] assume the existence of a happens-before assignment function that assigns a happensbefore relation to any execution sequence.The precision of such function can vary as long as it satisfies a set of properties, which relax those of [1] in order to consider the notion of observability.Let us recall the new properties related to the notion of observability.
112Definition 1 (observers(e, e ′ , E) [9]).Given an execution sequence E, and any two events e, e ′ ∈ dom(E) where e ⋖ E e ′ , there exists a set O = observers(e, e ′ , E) ⊆ dom(E) such that: 4. For every prefix E ′ of E such that e, e ′ ∈ dom(E ′ ):
5.
113If e≾ E e ′ , for all sequences w s.t.E.w is a sequence, and all events e ′′ ∈dom(E):
114• If e ↛ E e ′′ , then e ⋖ E.w e ′′ .
115• If e ′′ ↛ E e ′ , then e ′′ ⋖ E.w e ′ .6.For all e ′′ ∈dom(E) such that e ′ → E e ′′ , it holds that O ∩ observers(e ′ , e ′′ , E)=∅. 7. If O = {o} and E = E ′ .ô for some o and E ′ , then for any
116Intuitively, in the usual particular case of variable reads and writes, observers(e, e ′ , E) is the set of other events in E, independent of each other (by Property 2), that read the value written by e (e ′ ) for any variable also written by e ′ (e) (by Property 4).By an abuse of notation, we will sometimes treat this set as a sequence.
117From this point on, the presented algorithms will rely on such a generic happens-before assignment, i.e., one that considers observability and satisfies the above properties.In the examples we will continue to assume a concrete happens-before assignment based on the traditional approximation of dependency for programs with shared variables, extended to consider observability as follows.Two events p and q are considered dependent modulo observability if: (i) one enables the other, or (ii) one writes over a variable that the other reads, or (iii) both write over a variable that is later read by an observer.
118Example 8. Let us consider sequence E 1 = q.p.p.r.r.We have q 1 → E 1 p 2 since event r 1 is an observer of the race.However, event r 2 is not an observer in spite of reading variable x.This is because of Condition 2 of Definition 1 (r 1 is already an observer).On the other hand, r 2 is an observer of the race between q 1 and p 2 in sequence E 2 = p.r.q.p.r and hence we have q 1 → E 2 p 2 .Finally, in sequence E 3 = p.r.r.p.q we have p 2 ↛ E 3 q 1 since there is not an observer after them that reads the written value on variable x.
119The ODPOR ob algorithm of [9] corresponds to the code in black of procedure Explore of Algorithm 1 (excluding underlined blue parts) and the new RaceDetection procedure of Figure 5 with the original definition of notdep * of Section 2.2.Apart from the new happens-before assignment, the new support for handling observers corresponds to lines 4-6 of Figure 5. wut(E ′ ) := insert [E ′ ] (v, wut(E ′ )); Specifically, if the race between e and e ′ is observed (line 4), the race must be reversed and observed by the same observers.Thus, the last (max E ) observer o executed in E is selected (line 5) and used to compute v (line 6), where notobs * (e, e ′ , E)2 denotes the subsequence of E containing any process ê′′ such that e → E e ′′ , but e ′′ does not observe the race e ≾ E e ′ , and o ′ ↛ E e ′′ for any observer o ′ of the race.There is a small change in line 5 with respect to [9]: we select o as the last (rather than an arbitrary) observer from observers(e, e ′ , E).The reason for this will be clear in Section 4.3.
120Example 9.The exploration of ODPOR ob on our working example proceeds exactly the same as that of ODPOR (see Example 4) until state 34.This is because all write-write races until this point have a subsequent observer that reads the written value.As an example, see sequences E 2 and E 3 of Example 8.However, after exploring sequence p.r.r.p.q at state 34, ODPOR ob does not consider a race between p 2 and q 1 (since there is not a later observer) and hence it does not backtrack to state 32 to explore p.r.r.q.p (pruning P5 of Figure 1).Note that while the final value of variable x in these sequences is different (x = 1 vs. x = 2), ODPOR ob considers that this does not affect the program behavior, as the value is not read later.
The Basic "Union" Algorithm
121The ODPOR cs and ODPOR ob algorithms of Sections 3 and 4.1 can be combined simply by joining their codes together, that is, the code of procedure Explore of Algorithm 1 (including underlined blue parts) and the new RaceDetection procedure of Figure 5, adding the underlined blue code of the RaceDetection of Algorithm 1, including the enhancements of Sections 3.2, 3.3 and 3.4 and relying on the happens-before relation of Section 4.1.The exploration performed by such a "union" algorithm would be the intersection of the explorations of ODPOR cs and ODPOR ob , and its prunings the union of the ODPOR cs and ODPOR ob prunings.
122Example 10.In our working example such basic "union" algorithm proceeds as the ODPOR cs algorithm until state 34 and then, as ODPOR cs (see Example 9), it does not backtrack to state 32 to explore p.r.r.q.p.It is hence able to avoid the exploration of the states in boxes P1, P2, P3, P4 and P5 of Figure 1.
123This "union" algorithm can be seen in Algorithm 2, if we ignore the code underlined in red (which corresponds to the enhancements of Sections 4.3 and 4.4) and we take lines 76, 77 and 78 outside the scope of the else (as explained in Section 4.3).These modifications to the "union" algorithm are performed to exploit the synergy between the notions of contextsensitive independence and observability.The resulting algorithm is ODPOR ob cs .
124Algorithm let WuT ′ = subtree(wut(E), p);
125] then 78:
126dont := v.ê;
127add dont to dnd(E ′ );
1284.3.Refining the Context-Sensitive Check for Write-Write Races Consider again the race detection phase on our running example of Figure 1 after exploring sequence q.p.p.r.r.The "union" algorithm finds a reversible race q 1 ≾ E p 2 observed by r 1 .After setting v to p.p.q.r in line 71, the check s [q.p.p] = s [p.p.q] in line 77 fails (recall this line is temporarily assumed to be outside the else scope).Hence, nothing is added at this time to dnd(ϵ) and p.p.q.r is added to wut(ϵ).Interestingly, sequence p.p.q.r.r is equivalent to the already explored q.p.p.r.r from the point of view of the observer r 1 .I.e., although the value of variable x is different, the assert executed by r 1 holds in both cases.Note that this is not the case for the assert of r 2 (it holds in q.p.p.r.r but it does not in p.p.q.r.r), but since it is not an observer (due to Condition 2 of Definition 1) it does not need to be considered in this sequence (see Example 8).
129It thus seems natural in this case to perform an enhanced context-sensitive check that compares the states modulo observability, e.g., compares s [p.p.q.r] and s [q.p.p.r] only considering the effect of the observation performed by r 1 .Since in both cases it has the same effect (the assert holds), p.p.q.r could be added to dnd(ϵ), thus stopping the exploration of the fourth derivation at state 13.More precisely, given a race e ≾ E e ′ observed by o, we say that two states s and s ′ are equivalent modulo observability, written s W E (o) = s ′ (following the notation of Section 3.4), if the variables that are written by o have the same values in s and s ′ .Let us recall that in the case of observers with assertion statements, the result of the assertion is assumed to be written to a memory address and thus included in the W E (o) set.In the example above with E = q.p.p.r.r, the equality between s [p.p.q.r] and s [q.p.p.r] is performed only looking at the result of the assertion in r 1 .
130The implementation of the refined check corresponds to the underlined red code in lines 72, 73 and 74 of Algorithm 2. First, it sets o s to the subsequence of observer processes observers(e, e ′ , E).Then, after extending v with the required processes (see explanation below), it checks that for every observer process o ′ in o s (this time treated as a set), the state after executing o ′ is equivalent modulo observability to the state obtained by the alternative sequence E ′ .v≤ o E .(ôs \ ô), which contains the reversed race, followed by observer o and the remaining observers.
131As with the original context-sensitive check (see Section 3.3), in order to be effective, it is important not to include in v unnecessary processes before the reversed race, while at the same time including at the end those that are necessary to keep optimality.The solution is analogous to that of Section 3.3.First, unnecessary processes are taken away from sequence v (line 71).In particular, notdep * inherits the redefinition of Section 3.3, and notobs * (e, e ′ , E) is redefined as the subsequence of processes of E, excluding the occurrence e, whose events happen-before those in observers(e, e ′ , E).Finally, to ensure optimality, v is extended with I fut (E ′ , v, E) (line 71), to ensure it has enough information to detect redundancies.
132Note that all the predecessors of other observers are in v ≤ o E , thanks to the choice of o as max E (observers(e, e ′ , E)).Thus, we can execute ôs \ ô ( ô is already in v) without problem after E ′ .v≤ o E .Note also that we cannot use s [pre + (E,o)] to perform all the checks because, after every o ′ ∈ o s has been executed, there may be another event e ′′ < o ∈ E such that o ′ → E e ′′ , which would invalidate the check by modifying the value of the variables used in the check.That is why we use s [pre + (E,o ′ )] for each o ′ ∈ o s to perform each check in line 73.Another possibility, which could be more efficient in certain contexts (and does not require accessing these intermediate states), would be to perform all the checks with the state s [notdep * (e,e ′ ,E).ê.ê′ .(notobs* (e,e ′ ,E)\{ê}).ôs ] , where the race between e and e ′ has not been reversed.
133The following provides the intuition behind the need to consider every observer o ′ ∈ observers(e, e ′ , E) for the new check, rather than just the selected one o.Consider our running example with a simple modification: the instruction assert(x < 2); is executed by a different process r ′ , enabled from the initial state.Let the sequence E = q.p.p.r.r ′ be the initial exploration of the algorithm.For the race between q 1 and p 2 we have that observers(q 1 , p 2 , E) = {r 1 , r ′ 1 }.Let us assume the algorithm selects o := r.If the new check only considers event o 1 (instead of every o ′ ∈ o s ), the check succeeds (the assert holds in both cases) and, hence, p.p.q.r is added to dnd(ϵ).This would prevent the exploration of sequence p.p.q.r.r ′ (where the assert of r ′ 1 does not hold) which is not equivalent to any previously explored sequence.In this concrete example, this does not cause us to lose any different final result (the assert of r ′ 1 also fails in other combinations).However, this would not be the case in an example where the only possibility for the assert of r ′ 1 to fail would be to execute it after q.p.p.
134Note that the new enhanced check is only applied in the case of write-write races followed by an observer (i.e. when the algorithm enters the if of line 69) and that it can only be more precise than the original check.That is why in the final algorithm, the code of lines 76, 77 and 78 goes within the else scope, hence replacing the original check for the case of writewrite races.For races that are not observed, the original check is still applied in lines 77 and 78.
135Example 11.Let us consider the exploration performed by ODPOR ob cs on our running example of Figure 1 (recall that fragments in all boxes are pruned by ODPOR ob cs ).In the invocation to RaceDetection at state 5, i.e., after exploring sequence q.p.p.r.r, for the write-write race between q 1 and p 2 , the new enhanced context-sensitive check of line 73 only checks if the result of the assertion of r 1 is the same in both s [q.p.p.r] and s [p.p.q.r] (since we have observers(q 1 , p 2 , q.p.p.r.r) = {r 1 }), ignoring the value of variable x which is different.Since the check succeeds p.p.q.r is added to dnd(ϵ).This causes the pruning of box P6.The rest of the exploration proceeds as the "union" algorithm (see Example 10).Note that the enhanced check is also executed in the call to RaceDetection at state 24, i.e., after exploring sequence p.r.p.q.r, for the write-write race between p 2 and q 1 , but this time it fails since the assert of observer r 2 fails after p.r.p.q.r (where x = 2) but instead it succeeds in p.r.q.p.r (where x = 1).
Refining the Inheritance of Don't-Do Sequences
136One could expect that whenever a sequence w is added to a dnd(E ′ ) set of sequence E ′ due to the new refined check, a prefix of w be also added to wut(E ′ ).Indeed, if the refined check of line 73 succeeds, sequence v.( ôs \ ô) is added to dnd(E ′ ), and sequence v is inserted to wut(E ′ ).However, it is possible for the later sequence not to be added to wut(E ′ ) if it already contains an equivalent sequence (which had been added before).In such cases, the dnd sequence might not be propagated successfully during the exploration of the corresponding sequence in wut(E ′ ), resulting in unnecessary exploration.
137Example 12. Let us consider our running example but replacing process r by r : o = x; and exploring first sequence E 1 = p.q.q ′ .p.r, where q ′ is another instance of the same process q.For the race between q 1 and p 2 , the refined check builds the alternative sequence p.q ′ .p.q.r (note that q ′ happensbefore q in E 1 ).The obtained observation is o = 2, whereas in the original E 1 it was o = 1, hence q ′ .p.q.r is added to wut(p) but not to dnd(p).The algorithm explores four more sequences before backtracking to the root, including sequence E 2 = p.q.p.q ′ .r.In this case, for the race between q and q ′ , the refined check builds the alternative sequence p.p.q ′ .q.r (note that p happens-before q ′ in E 2 ).The obtained observation both in E 2 and p.p.q ′ .q.r is o = 2. Hence, p.q ′ .q.r is added to dnd(p) but not to wut(p), since it is equivalent to q ′ .p.q.r, which was added before.The propagation of dnd sequences in Algorithm 1 (underlined blue code of lines 19 and 20) is not able to propagate down p.q ′ .q.r when exploring q ′ .p.q.r, even though they are equivalent sequences.
138The refined propagation allows us to generalize the previous propagation of dnd sequences, which can be seen in the underlined red code of line 62 of Algorithm 2. Essentially, a sequence u.p.v will now be propagated as u.v, if p is independent of all processes in u.In addition, the new case can take advantage of observability using the information of the trace E ′ .u.p.v.We define E | = u.q.p.v q⋄ p if E.u | = q⋄ p, (i.e., they are unconditional independent), or ∃ ŵ ∈ v, such that the set of variables written both by p and q is overwritten by w and ∀r ∈ v that observes any of these variables, w < E.u.q.p.v r.Intuitively, this refined propagation allows transitively propagating equivalences between the dnd set and the WuT of a state.
139In the case of Example 12, when backtracking to p to explore q ′ .p.q.r, the sequence p.q ′ .q.r in dnd(p) is propagated down to dnd(p.q′ ) as p.q.r.This allows detecting p.q ′ .p.q.r as redundant.Indeed, p | = p.q ′ .q.r p 2 ⋄ q ′ 1 in p.q ′ .q.r since r 1 is not observing their effect (it observes the subsequent write q 1 ), whereas they would be dependent with the traditional notion of dependency.
140Let us finally point out that this refinement is also applicable to the ODPOR cs algorithm of Section 3.1, and also to the original DPOR cs algorithm of [4], although in these contexts it would be much less likely to be applied.
Correctness and Optimality
141The theorem for ODPOR ob cs is analogous to the one in Section Appendix A, but using the definition of equivalence modulo observability, introduced in Section 4.3.
142Theorem 3 (Soundness of ODPOR ob cs ).For each Mazurkiewicz trace T defined by the happens-before relation, Explore(ϵ, ⟨{ϵ}, ∅⟩,∅) of Algorithm 2 explores a complete execution sequence that either implements T , or reaches an equivalent state modulo observability as one that implements T.
143Theorem 4 (Optimality of ODPOR ob cs ).Algorithm 2 never explores two complete execution sequences that are equivalent.
144The proofs of the above theorems can be found in Appendix B.
Experiments
145This section reports on our experimental comparison of the performance of ODPOR [1], ODPOR ob [9], DPOR cs [4] and our proposed ODPOR cs and ODPOR ob cs .The major part of the experiments are performed using the Nidhugg tool [23], a stateless model checker for shared-memory pthreads programs written in C/C++ that operates by interpreting the LLVM intermediate representation.It is important to note that Nidhugg was developed and it is maintained by some of the authors of [1] and [9], and it is indeed used in the experimental evaluation of [9].It therefore includes implementations of the ODPOR and ODPOR ob algorithms.Our experimental evaluation has hence required the implementation and integration within the Nidhugg framework of the DPOR cs , ODPOR cs and ODPOR ob cs , as well as the implementation of the support to handle atomic blocks.
146We also use the SYCO tool [6], a systematic testing tool for message-passing concurrent programs written in the ABS modeling language [17], for the two largest benchmarks of [5] which were unsuitable to be translated into C/C++.
Goals of the Experimental Evaluation
147The goals of our experimental evaluation are the following:
148G1 Study the overall effectiveness in terms of scalability of ODPOR cs and ODPOR ob cs w.r.t ODPOR, DPOR cs and ODPOR ob .We expect cases where ODPOR ob cs produces exponential reductions over ODPOR ob and behaves similarly to DPOR cs and ODPOR cs (G1a), cases where it produces exponential reductions over DPOR cs and ODPOR cs , and behaves similarly to ODPOR ob (G1b), and, cases where it produces exponential reductions over all DPOR cs , ODPOR cs and ODPOR ob (G1c).We also expect cases where ODPOR ob cs may behave worse than either DPOR cs or ODPOR ob due to the overhead of either the observers or the context-sensitive part whenever it is not effective (G1d).Overall, we expect that ODPOR ob cs will often outperform or, at least, scale similarly than the best of the other algorithms.As regards ODPOR cs , we expect it to perform essentially equivalent to DPOR cs for most benchmarks (G1e).An explanation for this is found below in Section 5.3.G2 Observe the potential overheads that both the contextsensitive part (G2a) and the observers part (G2b) of the algorithm may produce.
149G3 Study the effectiveness of the context-sensitive check refinements of Sections 3.4 and 4.3.
Description of the Experiments
150We have used three sets of benchmarks: The first one is a subset of the classical concurrent programs used in [4] to compare Source-DPOR and DPOR cs .They feature typical distributed and concurrent algorithmic patterns, in which computations are split into smaller atomic subcomputations that concurrently interleave their executions, and work on shared data.Our set includes three concurrent sorting algorithms (pipesort, mergesort and quicksort), a distributed workers algorithm (pi), a concurrent fibonacci algorithm (fib), and a producer-consumer algorithm (boundedbuffer).
151Our second set of benchmarks contains the synthetic programs used in [9] to compare ODPOR and ODPOR ob and some variations of them.Benchmarks lastwrite, floatingread and lastzero correspond to benchmarks of the same name in [9], and abs corresponds to the running example of [9]'s figure 1 generalized for n processes.Benchmarks ending with -2phases and -dif are variations of the above for the corresponding prefix.Specifically, the -2phases variations perform 2 repetitions of the code pattern in each process so that potential exploration reductions can be better observed.The -dif variations write different values to all shared variables, hence context-sensitive checks cannot take advantage of context-sensitive dependencies.That allows us to reason about the worst-case scenario for the context-sensitive part of the algorithms.We also include in this second set arraywrite, a synthetic benchmark to illustrate the potential impact of the refined check of Section 3.4, which consists of 4 * N processes writing an N-array and two processes reading the first two positions.
152Each benchmark is executed for a series of increasing input parameters in order to observe the impact of the reductions and overheads on bigger explorations.Tables 1 and 2 show the results of the executions of ODPOR, ODPOR ob , DPOR cs and ODPOR ob cs for the first and second set of benchmarks respectively.The results for ODPOR cs are not shown in the tables since they are basically the same as those of DPOR cs .Column LE/LT shows the length of the longest execution sequence in terms of execution steps (LE) and the length of the longest trace in terms of LLVM instructions (LT ).Note that such a longest execution sequence and corresponding trace is the same on every algorithm.This gives an idea on the complexity and depth of the exploration which is carried out.Also, the difference between the LE and LT values on a given exploration provides an indication on the length of the atomic blocks of the benchmark (the bigger the difference the longer the atomic blocks).Columns labeled with E show the number of finished execution sequences whereas those with T show the time in seconds of the whole exploration.Times are obtained on an Intel(R) Core(TM) i7 CPU at 2.5Ghz with 8GB of RAM (Linux Kernel 5.4.0).Columns G cs−ob cs and G cs−ob ob show the time speedup of ODPOR ob cs over DPOR cs and ODPOR ob , respectively, computed by dividing their respective times by that of ODPOR ob cs .A timeout of 150 seconds is set.When reached, we write -, except for the speedups of the first input for which the timeout is reached, in such case we write >X to indicate that the speedup would be X if the process finishes right in the timeout, and hence it is guaranteed to be greater than X.Finally, our third set of benchmarks (Table 3) are run within the SYCO tool and include two larger programs implemented in the ABS modeling language using active objects and messagepassing: MapRed, an implementation of a map-reduce model developed by a company (440 lines of code); and SDN [8], a model of a software-defined network featuring a safety policy violation (490 lines).
Analysis of the Results
153We have confirmed that ODPOR cs performs basically equivalent to DPOR cs (goal G1e).The number of finished execution sequences is exactly the same for all benchmarks.The execution time is also basically the same with a very slight overhead (of at most 4%) due to the handling of the wakeup trees.An exception for this is the lastzero benchmark where ODPOR cs outperforms DPOR cs (e.g., for N = 6, ODPOR cs takes 0.24s vs. the 0.34 of DPOR cs ).It is already shown in [1] that even though optimality provides a very relevant and strong theoretical result, it is difficult to find examples where ODPOR produces significant improvements in practice over Source-DPOR.The lastzero benchmark is indeed the only case where this happens in [1].Note also that the primary goal of the development of ODPOR cs is to serve as an intermediate and necessary step towards the development of our finally proposed algorithm which is ODPOR ob cs .
154Looking at the results on our first set of benchmarks (see Table 1) we clearly observe that ODPOR ob cs always outperforms or behaves similarly to the best of the other algorithms (goal G1).For instance, in pipesort we observe that ODPOR ob and DPOR cs both feature exponential reductions over ODPOR and that ODPOR ob cs is able to produce exponential reductions over both of them (goal G1c).This is due to the benefits of combining the orthogonal reductions of ODPOR ob and DPOR cs and, also to the synergy of the combination (namely the refinement of Section 4.3) (goal G3).In quicksort, mergesort, fib and boundedbuffer we can observe that ODPOR ob performs almost identically to ODPOR since there are no observers to take advantage of.We also observe exponential reductions of both DPOR cs and ODPOR ob cs over both ODPOR and ODPOR ob due to context-sensitive dependencies (goal G1a).We can hence observe the overhead of the observers part of the algorithms in isolation (goal G2b) which is very low (see e.g. the times of ODPOR ob cs versus those of DPOR cs ).
155In pi we have a different situation.We observe exponential reductions of both ODPOR ob and DPOR cs w.r.t ODPOR indicating there are both observers-based independences and also context-sensitive independences.In this case, the combination of the reductions due to both kind of independences produced by ODPOR but, interestingly, not over DPOR cs , which behaves similarly to ODPOR ob cs (goal G1).This indicates that the prunings performed by ODPOR ob are in this case a subset of those produced by DPOR cs , hence joining them does not produce an improvement over the best of both algorithms (here DPOR cs ).
156In the second set of benchmarks (see Table 2) we can observe exponential reductions in the number of finished executions in ODPOR ob cs w.r.t all ODPOR, DPOR cs and ODPOR ob .Note that ODPOR ob cs is able to catch all redundant executions hence obtaining only 1 finished execution.Again, that is possible both due to the combination of ODPOR ob and DPOR cs and, also to the new refined check of Section 4.3 (goal G3).However, such a reduction over ODPOR ob does not have a direct correlation to a corresponding reduction in time in neither lastwrite nor floatingread nor abs.This indicates that the overhead of the context-sensitive part of the algorithm does not pay-off in these cases, mainly because the reductions are being done at the very end of the executions and hence few states are being pruned (goal G1d).This can indeed be observed looking at the results we get in the -dif variations of the benchmarks where the variable writes are all done with different values, hence making all context-sensitive checks to fail.We observe that in these cases ODPOR ob cs performs similar, and even better, as it does with the original benchmarks in terms of exploration time, clearly indicating that the prunings being made are not saving exploration effort.This is because of the overhead due to the handling and inheritance of the don't-do sets, which in the case of the -dif variations is not produced since there are no don't-do sets to be handled (goal G2a).
157Although it is not shown in the tables (in order not to overload them with more data) we are also measuring the number of executions which are cut due to don't-do sets (don't-do set blocked executions, DDSBs).Note that the number of DDSBs with ODPOR ob cs would be always bounded (above) by the difference between the number finished execution sequences of ODPOR ob and ODPOR ob cs (and the same with ODPOR cs and ODPOR, respectively).But it could be much less than that because by blocking a partial execution, we can be avoiding the exploration of several redundant complete executions that will be explored by ODPOR ob (or ODPOR).Indeed, the number of DDSBs would be a direct indication of the effectiveness of the context-sensitive checks.The more close to the above upper bound the less effective are the checks since that would mean that the total number of explored executions (including the DDSBs) would be close to the total number of executions explored by ODPOR ob .E.g., in the case of pi for N = 7, the number of DDSBs is 750 which means that ODPOR ob cs is exploring a total of 1022 executions (including the DDSBs) whereas ODPOR ob is exploring 5040.However, in the case of lastwrite we get 3, 7, 11 and 15 as the numbers of DDSBs for the four runs respectively, which means that ODPOR ob cs is exploring the same number of executions as ODPOR ob although most of them are cut at the end (since they are redundant).The results on the rest of the benchmarks confirm this claim: in the cases where G cs−ob ob ≤ 1, the total number of explored executions of ODPOR ob cs (including DDSBs) is close (or even equal, as in the case of lastwrite) to the number of explorations performed by ODPOR ob , whereas in the cases where G cs−ob ob grows, such number is much lower.
158The fact that ODPOR ob cs is able to catch many more redundant executions than ODPOR ob , as we have seen, does not necessarily indicate a reduction on the overall exploration time (due to the associated overheads).However, this indicates the potential of ODPOR ob cs to produce exponential reductions.That will hap-pen as soon as the pattern where the reduction takes place is followed by non-trivial explorations, in such case such upcoming explorations will be effectively pruned.This can be observed looking at the results obtained in the -2phases variations of the benchmarks where we can see such exponential reductions of ODPOR ob cs w.r.t both ODPOR ob and DPOR cs (goal G1).The results from the third set of benchmarks give evidence of the potential of our algorithm when applied over larger programs.For MapRed, both ODPOR ob cs and DPOR cs explore 9 executions in 185 ms. and 114 ms.respectively, while ODPOR ob explores 118 executions and takes almost 3 seconds, since there is no gain in using observers in this case.For In conclusion, our experimental results show that our algorithm ODPOR ob cs is able to effectively combine the benefits of both DPOR cs and ODPOR ob .On the other hand, we can observe that it also inherits their associated overheads.Whereas in the case of ODPOR ob the overhead is very low, our results show notable overheads in DPOR cs and hence ODPOR ob cs , which in some cases do not pay-off even though they do not seem to affect the overall scalability.In this sense, we believe that the integration of the optimizations proposed in [4] could help.Specifically, we have measured that nearly half of the exploration time in both DPOR cs and ODPOR ob cs is spent in the computation of the alternative execution sequences for the context-sensitive checks (that are later recomputed during the normal exploration), which we believe could be avoided (at least in part) by integrating the support to avoid recomputations described in [4].
159Finally, let us conclude this section by noting that DPOR cs , ODPOR cs , and, consequently, ODPOR ob cs are likely to be highly beneficial for programs with large atomic code sections (e.g., monitors, concurrent objects, and message-passing systems), where the usual approximation of dependency based on variable accesses, even if it is computed dynamically, can be rather imprecise.They are also likely to be beneficial for programs with assertions, as these only result in two possibly (local) states: either the assertion holds or it does not.Hence, the contextsensitive independence check is more likely to succeed.
Conclusions and Related Work
160DPOR is one of the most scalable techniques used in the verification of concurrent systems.Recent work has introduced orthogonal notions of conditional independence into DPOR: DPOR cs [4] proposes a context-sensitive check in the current state to detect more accurately independence among processes, ODPOR ob [9] proposes a finer notion of independence which is conditional to the existence of observers that read the values written by the processes.We propose a seamless integration of DPOR cs and ODPOR ob , via two major technical extensions to DPOR cs : (1) incorporating (and using effectively) the notion of wakeup tree used by ODPOR ob , and (2) refining the contextsensitive check (and the sequences computed with it) to take observers into account.As shown in our experimental evaluation, the resulting algorithm achieves prunings that go beyond the combination of the individual algorithms.
161Other recent approaches have considered alternative ways of refining the detection of independence.Data-Centric DPOR [11] was the first work to focus on the reads-from relation.It defines two traces to be observationally equivalent if every read event observes the same write event in both traces.In contrast, we use the notion of observability introduced by [9], which is based on observing interference of operations, not just individual writes.The equivalence relation used by Data-Centric is proven in [11] to see more traces as equivalent than the one based on Mazurkiewicz traces, which is the one used in our work and in all other variants of the DPOR algorithm of [13].Note that this is more unlikely to happen in programs with bigger atomic blocks like our first and third set of benchmarks (where we have indeed seen that the reads-from relation would not be exploited).A drawback of Data-Centric DPOR is that it is not always optimal.Recently, there have been other works proposing optimal DPOR algorithms based on the reads-from relation, either for sequential consistency [2], for the releaseacquire semantics [3] or for the C/C++ concurrency.Also, [22] proposes an optimal algorithm for the reads-from relation which is parametric in the choice of the memory model under a set of basic assumptions.This has been recently further extended to handle locks efficiently [21] and, for the first time, to ensure linear memory consumption per equivalence class while at the same time allowing parallelization [20].It remains to be studied whether our context-sensitive dependency can be successfully integrated within these approaches based on the readsfrom relation since their underlying algorithms are fundamentally different as the classical DPOR algorithm and its variants (including [9]).
162Another approach is to generate independence constraints (ICs), which ensure the independence of each pair of processes in the program.The work in [32,18] generated for the first time ICs for processes with a single instruction following some predefined patterns.Constrained DPOR [7] proposed to generate ICs in a pre-phase, using a SMT solver.The generated ICs are then used within DPOR in a similar way to our contextsensitive checks.In addition, it can perform another type of pruning using the notion of transitive uniform conditional independence -which ensures the ICs hold along the whole execu-tion trace (and ensures uniformity as defined in [19,16]).The extension of Constrained DPOR with observers, to the best of our knowledge, has not been studied yet.We believe the integration of wakeup trees could be done similarly to our proposal in Section 3.1, and the enhancements in Section 4 would be applicable also in the Constrained DPOR framework.Still, the combination of transitive uniformity and observability remains to be investigated.
163An orthogonal approach to increase scalability, introduced in Quasi-Optimal POR [26], is to approximate the optimal exploration using a provided constant k.In essence, by using approximation, alternatives are computed in polynomial time, rather than making an NP-complete exploration, as in ODPOR.Another orthogonal improvement is to inspect dependencies over event chains [29].This work has been recently extended to the context of symbolic execution [30], where cut-off events are used to detect program states already visited in order to handle non-terminating executions.
164Finally, there is a large body of related work in the context of dynamic runtime verification that include similar ideas for race and deadlock detection [28,10,27].For instance, [28] proposes a complete and sound algorithm that predicts all data races of a given trace but without considering observability, whereas [10] improves it by taking into account observability.
Appendix A. Proofs of Correctness and Optimality of ODPOR cs
165Let us claim some auxiliary lemmas and definitions before proving the main theorems of soundness and optimality.First, we claim a lemma needed to prove the correctness of the new context-sensitive check.
166Let the sequence E ′ = E 0 .ê.w.ê′ .w′ is explored by Algorithm 1 and the race e ≾ E ′ e ′ .According to the algorithm's definitions: E 0 = pre(E ′ , e) and v = notdep(e, e ′ , E ′ ).
167Lemma 1.If the following check of Algorithm 1 succeeds
168Proof.First, we know that E ′ = E 0 .ê.w.ê′ .w′ , then pre + (E ′ , e ′ ) = E 0 .ê.w.ê′ , and sequence ê.w, can be divided in two sets notdep(e, e ′ , E ′ ) and suc(e, E ′ ).
169Let us introduce a simple notation suc − (e, E ′ ) to denote the sequence suc(e, E ′ ) without the first process ê.Then, E 0 .ê.w.ê′ ≃ E 0 .ê.notdep(e, e ′ , E ′ ).suc − (e, E ′ ).ê′ ≃ E 0 .notdep(e,e ′ , E).ê.ê′ .suc(e,E ′ ) (taking into account that after E 0 .notdep(e,e ′ , E).ê, we have ê′ ⋄ suc − (e, E ′ )).Because of the hypothesis, we know that s , then the write instruction must depend on a value of another variable x in a condition.This variable must be different in both states after the execution of ê. ê′ and ê′ .ê,respectively.However, this is not possible since x must be modified by e or e ′ and then, x ∈ V e,e ′ E ′ , and, thus, by the initial hypothesis, x should have the same value, producing the same result in the condition of variable y.We get a contradiction.
• If y
170V e,e ′ E ′ we get a similar contradiction.Since they write different values over variable y, and both executions share the same prefix E 0 .notdep(e,e ′ , E), there must be a variable in V e,e ′ E ′ with a different value.Otherwise, the value of y must be the same in both executions.
171Consequently, we have that for every program variable y s
172] (y).
173The correctness of the ODPOR cs algorithm follows from the correctness of ODPOR, and the fact that context-sensitive checks only remove equivalent Mazurkiewicz traces.] , then for any complete sequence E of the form E = E 0 .v.ê.u ′ .w′ that contains a race e ′ ≾ E e, there is a complete sequence E ′′ = pre + (E ′ , e ′ ).w that defines a different Mazurkiewicz trace T ′ =→ E ′ and leads to an identical final state.
174Proof.Let E = E 0 .v.ê.u ′ .w′ be a complete execution sequence.Let us notice here that Proof of Theorem 1 (Soundness of ODPOR cs ).Consider an execution of Explore(ϵ, ⟨{ϵ}, ∅⟩, ∅) without the additions for context-sensitivity, and assuming we always choose an enabled process (if it is possible, from the wakeup tree) that would not be blocked by the don't-do set in the extended algorithm, wherever possible.This is exactly the ODPOR algorithm of [1] which is guaranteed to explore a complete execution sequence that implements each T [24].
175Suppose that some Mazurkiewicz trace T is omitted by ODPOR cs , C is the complete execution sequence that implements T (T =→ C ) and is explored by the original ODPOR algorithm.This sequence must be cut by our algorithm.Thus, it must be of the form C = E ′ .v′ .ê.y, where our algorithm added v.ê to dnd(E ′ ) after succeeding in the check exploring a sequence C ′′ , and v ′ .ê is v.ê possibly having added some events that do not depend on any event in dom [E ′ ] (v.ê), as otherwise the don't-do entry would have been removed.Hence, there exists a complete execution sequence E ′ .v.ê.w.y with the same happens-before relation as C, obtained by moving after v.ê events that are independent of v.ê (those with processes in w).By Lemma 1, we can apply Lemma 2 and we get that there is a different trace T ′ which leads to the same state as C. Since ODPOR explores a complete execution sequence for each Mazurkiewicz trace, it must include a complete execution sequence C ′ that implements T ′ .Note that C ′ has the same happens-before relation as C ′′ = pre + (C ′′ , e ′ ).w.y.
176We now show that C ′ must have been explored before C, i.e. it appears to the left of C in the ODPOR exploration tree.Sequence pre + (C ′′ , e ′ ) clearly appears to the left of C in the ODPOR tree, or it could not be used to add the don't-do entry that blocked C. Let us suppose instead that C ′ appears to the right of C in the exploration tree.Let E ′′ be the largest common prefix of C and C ′ .Now C = E ′′ .q.w ′ for some q.Since C ′ appears to the right of C, then q will be in the don't-do sets for (the remainder of) sequence C ′ unless it is removed by some dependent event.Let e ′ = next [E ′′ ] (q), that is, the next event that q executes after E ′′ .
177Suppose that E ′′ .q≤ E ′ , then the first change is above E ′ .The happens-before relation for C ′ must then have some event e ′′ (after E ′′ .q)such that e ′′ → C ′ e ′ , but this cannot be the case since → C ′ =→ pre + (C ′′ ,e ′ ).w.y where this does not occur.
178Suppose that E ′ ≤ E ′′ and, thus, the first change is at, or after, the point where pre + (C ′′ , e ′′ ) and E ′ .v.ê differ.Clearly C ′ must appear to the right of E ′ .(e) in the tree (otherwise it would be to the left of C).Hence, ê is in the don't-do set (for the remainder) of C ′ after E ′ until removed by dependent events.Suppose event e ′′ removes ê.Then, we have that e ′′ → C ′ e.This is a contradiction since this does not occur in pre + (C ′′ , e ′ ).w.y.
179Hence, C ′ must appear to the left of C in the ODPOR tree.If C ′ exists in the tree visited by ODPOR cs we are done, since we have found an equivalent complete sequence.Otherwise, we can apply the same construction to discover an equivalent complete sequence that occurs to the left in the original tree.The procedure must terminate since, eventually, we reach the leftmost branch, which cannot be removed by the context-sensitive additions to the algorithm.Now, let us claim a lemma needed for the optimality theorem.Lemma 3. Let E = E ′ .ê.w.ê′ .wbe an execution such that e ≾ E e ′ .Let v ′ and v be dep(e ′ , E). ê′ .I fut (E ′ , v, E) and notdep * (e, E). ê′ , respectively.v redundant(E ′ , done) ⇔ v ′ redundant(E ′ , done) Finally, let us sketch the proof of Theorem 2.
180Proof sketch of Theorem 2 (Optimality of ODPOR cs ).This theorem follows from: (1) the optimality of ODPOR, (2) the fact that the algorithm can cut executions that are not happensbefore equivalent but whose result is the same as that of other complete executions already explored (Lemma 2), and (3) the fact that races found in cut executions have enough information to detect redundancies correctly (Lemma 3).By Lemma 3, we detect the same redundancies than ODPOR, whenever ODPOR cs explores a don't-do set blocked execution E.Then, when detecting a race in E, the wakeup tree is updated if and only if it would also be updated in case E would have been completely explored.Consequently, if both algorithms detect the same redundancies, and ODPOR does not initiates any of them, ODPOR cs does not either.The happens-before relation used in ODPOR requires (by the soundness of ODPOR) to explore an equivalent execution to E. Let us notice that E does not have the same happens-before relation than any execution explored by ODPOR cs .Lemma 5 (soundness of new inheritance).Let E ′ be an execution such that p.q.u ∈ wut(E ′ ), q.p.u.v ∈ dnd(E ′ ), and E ′ | = q.p.u.v p ⋄ q.If E = E ′ .p.q.u.v and E ′′ = E ′ .q.p.u.v, then s [E] = s [E ′′ ] modulo observability.
181Proof.Let us distinguish two cases depending on E ′ | = q.p.u.v p ⋄ q:
182• If E ′ | = q.p.u.v p⋄q holds because E ′ | = p⋄q, then they are independent, hence E ′ .p.q ∼ E ′ .q.p ⇒ s [E ′ .p.q] = s [E ′ .q.p] ⇒ s
183• Otherwise, E ′ | = q.p.u.v p ⋄ q holds because it takes advantage of observability, (i.e., ∃ ŵ ∈ u.v such that the set of variables written by both p and q is overwritten by w and ∀r ∈ u.v that observes any of these variables, w < E ′ .q.p.u.v r).Then, u.v is of the form u 1 .ŵ.u 2 .r.v 3 for all r ∈ u.v, and, although s [E ′ .p.q] may be different to s [E ′ .q.p] , we know that s [E ′ .p.q.u 1 .ŵ] = s [E ′ .q.p.u 1 .ŵ] and hence
184The proofs of soundness and optimality of ODPOR ob cs are analogous to those of the soundness and optimality theorems of ODPOR cs relying on Lemmas 4 and 5.
Figure 1 :
185Figure 1: Execution tree computed by the ODPOR algorithms for our running example.Subtrees P1 to P4 (dashed boxes in blue) are pruned by ODPOR cs and DPOR cs ; P5 (dotted box) is pruned by ODPOR ob and P1-P6 are all pruned by ODPOR ob cs .Arrow labels indicate the scheduled process; upper node labels the wakeup trees (v + w is a tree with two traces); and lower node labels (in blue) the don't-do sets (dnd).
Figure 2 :
186Figure 2: Main actions performed by ODPOR on Example 4
Figure 3 :
187Figure 3: wut(ϵ) at state 10 in Example 4
Example 6 .
188Let us explain the exploration performed by ODPOR cs on our running example, which is shown in Figure 1.The lower node labels (in blue) that start with ¬ indicate sequences in the corresponding don't-do sets, and the nodes within dashed boxes (labeled P1, P2, P3 and P4) correspond to
Figure 4 :
189Figure 4: Main actions performed by ODPOR cs on Example 6
Example 7 .
190Let us illustrate the need for each of the terms above with the following examples of events e, e ′ and execution sequence E = e.e ′ :
1 . 2 .
191For all o ∈ O, it holds that e → E o, o e ′ , and o ↛ E e ′ .For all o, o ′ ∈ O, it holds that o ↛ E o ′ .3. If E ′ ≃ E, then observers(e, e ′ , E ′ ) = O.
1 : 4 : 6 :: else 8 :
192procedure RaceDetection(E) 2: for all e, e ′ ∈ dom(E) such that e ≾ E e ′ do 3: let E ′ = pre(E, e); if observers(e, e ′ , E) ∅ then 5: let o = max E (observers(e, e ′ , E)); let v = notdep * (e, e ′ ,E).ê′ .ê.(notobs * (e, e ′ ,E)\ ê′ ).ô; 7let v = notdep * (e, e ′ , E). ê′ ; 9: if v redundant(E ′ , done) then 10:
Figure 5 :
193Figure 5: RaceDetection of ODPOR ob [9]
Lemma 2 .
194If the following check of Algorithm 1 succeeds s[pre + (E ′ ,e ′ )] = s [E 0 .(v.suc(e,E ′ )) ≤ e ′ E ′
s
195[pre + (C ′′ ,e ′ )] V e,e ′ C ′′ = s [E ′ .(v.ê) ≤ e ′ C ′′ ]
Lemma 4 .
196Appendix B. Proofs of Correctness and Optimality of ODPOR ob csLet us prove two lemmas that are the key for the soundness and optimality of Algorithm 2. If Algorithm 2 checks that s[pre + (E ′ ,o ′ )] = e,e ′ o ′ s [E 0 .v≤ o E ′ .(ôs \ ô)]∀o ′ ∈ o s , then for any complete sequence E of the form E = E 0 .v.( ôs \ ô).w ′ that contains a race e ′ ≾ E e observed by o s = observers(e, e ′ , E) and o = max E (o s ), there is a complete sequence E ′ = pre + (E ′ , o).w that defines a different Mazurkiewicz trace T ′ =→ E ′ and leads to an identical final state modulo observability.Proof.Let E = E 0 .v.( ôs \ ô).w ′ be a complete execution sequence.Here, let us denote notobs(e, e
Table 1 :
197Experimental evaluation results.First set of benchmarks.
Table 2 :
198ob cs features exponential reductions over ODPOR ob Experimental evaluation results.Second set of benchmarks.
Table 3 :
199Experimental evaluation results.Third set of benchmarks.
200SDN, ODPOR ob cs explores 16 executions in 52 ms., whereas DPOR cs explores 22 executions in 83 ms. and ODPOR ob 58 in 229 ms.Finally, in order to illustrate the potential impact of the refined check of Section 3.4 in isolation, the following table shows the exploration times of ODPOR ob cs with and without the refined check (columns labeled respectively With 3.4 and Without 3.4) on the arraywrite benchmark for a series of increasing inputs (column N), and the corresponding speedups.
201e ′ ,E).ê′ .ê].Let us suppose there exists a variable y such thats [pre + (E ′ ,e ′ )] (y) s [E 0 .(v.suc(e,E ′ )) ≤ e ′ [E 0 .notdep(e,e′,E).ê′ .suc(e,E′)](y).Two cases can be distinguished:• If y ∈ V e,e ′ E ′ , then because of the hypothesis we know that the value of y is not modified by suc − (e, E ′ ) at state s [E 0 .notdep(e,e′ ,E).ê.ê′ ] .But it is modified by suc − (e, E ′ ) at state s [E 0 .notdep(e,e′ ,E).ê′ .ê]
202′ ,E).ê.ê′ .suc− (e,E ′ )] (y) s
2031. E 0 .v≃E0.v≤e′E ′ .v>e′E′ , 2. E 0 .v.ê.u ′ ≃E 0 .v.suc(e, E ′ ) < e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′,wherew ′′ are possibly some events added that do not depend on any event in dom [E 0 .v](suc(e,E′)) and 3.E 0 .v≤e′ E ′ | = v > e ′ E ′ ⋄ suc(e, E ′ ) < e ′ E ′ .Now, E ≃ 1,2 E 0 .v≤e′ E ′ .v>e′ E ′ .suc(e,E′ ) < e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′≃ 3 E 0 .v≤e′ E ′ .suc(e,E′ ) < e ′ E ′ .v>e′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′≃ E 0 .(v.suc(e, E ′ )) ≤ e ′ E ′ .v>e′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′Since s [pre + (E ′ ,e ′ )] = s [E 0 .(v.suc(e,E ′ )) ≤ e ′ E ′ ] , we have that s [E ′′ ] = s [E] where E ′′ = pre + (E ′ , e ′ ).w and w = v > e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′.Note that in execution sequence E we have e ′ → E e, whereas in E ′ , we have e → E ′ e ′ .After claiming the previous lemmas, let us prove now the soundness of ODPOR cs .
204′ , E) as notobs and notice that E = E 0 .v.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs.ô.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs < o E .notobs>oE .ô.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs < o E. ô.notobs > o E .(ôs\ ô).w ′ ∼ E 0 .v≤o E .(ôs\ ô).v > o E .w′= E 0 .v≤o E .(ôs\ ô).wSince s [pre + (E ′ ,o ′ )] = e,e ′ o ′ s [E 0 .v≤o E .(ôs\ ô)] ∀o ′ ∈ o s , we have that s [E] is equivalent to s [E ′ ]modulo observability where E ′ = pre + (E ′ , o).w.Note that in E we have e ′ → E e, whereas in E ′ we instead have e → E ′ e ′ .
참고문헌 16건
- Partial-Order Methods for the Verification of Concurrent Systems: An Approach to the State-Explosion Problem 1996
- Peephole Partial Order Reduction Tools and Algorithms for Construction and Analysis of Systems · 2008 10.1007/978-3-540-78800-3_29
- State space reduction using partial order techniques International Journal on Software Tools for Technology Transfer · Springer Science+Business Media · 1999 10.1007/s100090050035
- Defining conditional independence using collapses Theoretical Computer Science · Elsevier BV · 1992 10.1016/0304-3975(92)90054-j
- Data-centric dynamic partial order reduction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2017 10.1145/3158119
- Optimal Dynamic Partial Order Reduction with Observers Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-319-89963-3_14
- SDN-Actors: Modeling and Verification of SDN Programs Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-319-95582-7_33
- Optimal stateless model checking under the release-acquire semantics Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2018 10.1145/3276505
- Optimal context-sensitive dynamic partial order reduction with observers 2019 10.1145/3293882.3330565
- Unfolding-based Partial Order Reduction International Conference on Concurrency Theory · 2015 10.4230/lipics.concur.2015.456
- Effective lock handling in stateless model checking Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3360599
- Optimal stateless model checking for reads-from equivalence under sequential consistency Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3360576
- Fast, sound, and effectively complete dynamic race prediction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3371085
- Dynamic Analysis Method for Concurrency Bugs in Multi-process/Multi-thread Environments International Journal of Parallel Programming · Springer Science+Business Media · 2020 10.1007/s10766-020-00661-3
- Truly stateless, optimal dynamic partial order reduction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2022 10.1145/3498711
- Trace theory Lecture notes in computer science · Springer Science+Business Media · 1987 10.1007/3-540-17906-2_30