Definition
Partial-order reduction is a technique that lets a model checker §3.30, a tool that explores every reachable state §3.21 of a system, skip orderings of concurrent actions that cannot affect the property being checked. Two actions are commuting actions in a state when they can run in either order from that state and both orders end in the same state. For actions that are independent, meaning that they commute and neither enables nor disables the other wherever both can run, the checker explores one representative order instead of every order.
The idea
A model checker examines concurrent software by exploring interleavings: the orders in which the actions of separate threads, tasks or devices can run. Many interleavings differ only in the order of actions that do not interact. With tasks that each set their own flag, there are orders through states, all ending in the same final state; 3 tasks already give orders. This growth is part of state explosion §3.26, the main practical limit of model checking.
The intuition is two people writing on separate sheets of paper: who writes first changes neither sheet. A run is then better described by a partial order §19.2.6, which records only which actions must come before which, than by one sequence. All sequences consistent with one partial order are equivalent, and checking one of them is enough if the property cannot tell them apart. The picture breaks when someone looks halfway through: a property that compares the two sheets, an observer, or a crash between the two actions can tell which went first.
How it works
Partial-order reduction works in three steps.
Decide which actions are independent. Two actions are independent when, in every state where both are enabled, meaning allowed to run, neither disables the other and they commute. Tools approximate this from read and write sets: two actions count as independent when neither writes a variable that the other reads or writes, including the variables of the other’s enabling condition. Any pair not shown independent is treated as dependent, which costs reduction but never hides a behavior.
Mark the visible actions. An action is visible when it can change the truth of a basic statement (an atomic proposition) that the property mentions, such as “”.
At each state, explore a subset of the enabled actions, called an ample set; related methods call it a persistent set or a stubborn set. Four conditions, given under Stated precisely, make this safe. In short: the subset is empty only when nothing is enabled; no action outside it that depends on an action in it can run first; it holds only invisible actions unless it holds every enabled action; and no enabled action is postponed forever around a cycle.
Sleep sets add a further saving: they record actions whose continuation has already been explored in an equivalent order, so the same pair of independent actions is not explored in both orders. Dynamic partial-order reduction, introduced by Flanagan and Godefroid in 2005 [439], discovers dependence during exploration from the memory locations that actions actually touch, which helps where a static analysis §3.1 cannot tell whether two pointer or array §14.5 accesses meet.
Worked example
Two tasks run at the same time. Task 1 performs action , which writes record : . Task 2 performs action , which writes record : . A state is the pair , starting at . Full exploration finds 4 states, 4 steps and two orders: then visits , , , and then visits , , . Both orders are possible and end in , and neither write disables the other, so and are independent.
Let the property be “if then ”: record is a selector that may announce record only after is written. The order then passes through and violates it. A reduction based on independence alone would explore only at , visit , and , and report no violation. The visibility condition, C2 under Stated precisely, prevents this: both writes change a record the property mentions, so both are visible, the ample set at must hold both, and both orders are explored.
A crash between the writes is handled the same way. Model it as an action , enabled in every state, that stops both tasks and keeps the records as they are. disables and , so it depends on both. By condition C1, an ample set at that holds must also hold , which depends on and could otherwise run first, and then also , which depends on . The reduction therefore keeps a crash at both and , which a recovery routine may treat differently.
Where the reduction applies, the saving is large. Take tasks that each write their own record and a property that mentions none of the records. The full state graph has states, one for each set of finished tasks, and steps. An ample set of one write per state meets all four conditions and leaves states and steps. For , 1024 states and steps shrink to 11 states and 10 steps, and orders shrink to one.
Stated precisely
Let be a state and an action. Write for the set of actions that can run in , and for the state that produces from . An independence relation is a symmetric set of pairs of distinct actions such that, for every pair and every state in which both and are in : Two actions that are not independent are dependent.
Two finite sequences of actions are equivalent when one can be turned into the other by repeatedly swapping two adjacent independent actions. The equivalence classes are called Mazurkiewicz traces, after Antoni Mazurkiewicz. Each class corresponds to one partial order of the action occurrences, which gives the technique its name.
Let , a subset of , be the set of actions that the reduced search explores from . In the formulation of the textbook Model Checking by Clarke, Grumberg and Peled [524], the conditions are:
- C0
-
is empty only if is empty.
- C1
-
On every path of the full state graph that starts at , no action that depends on an action in runs before some action in runs.
- C2
-
If , every action in is invisible: it never changes the truth of a basic statement that the property mentions.
- C3
-
No cycle of the reduced state graph contains a state in which some action is enabled that is in the ample set of no state on the cycle.
The guarantee: let be a formula of linear temporal logic, a logic of properties of single runs such as “always ” for a basic statement , that does not use the next operator, “in the very next state”. If C0 to C3 hold at every explored state, the reduced state graph satisfies if and only if the full state graph does. The next operator is excluded because the reduction changes how many invisible steps lie between visible ones. The guarantee assumes a correct independence relation and visibility marking, and a model that includes, as actions, every crash and observer that the property must cover.
Limits and common mistakes
Equal final states are weaker than equivalent runs: the intermediate states differ, and a property, an observer or a crash can see them.
Different record names do not prove independence. Hidden shared state makes writes dependent: one append position in a log, one erase block of flash memory §6.6 (a region erased only as a whole), one count of free space, or one checksum §4.32 over both records.
A shared limit makes writes disable each other: with room for one more record, whichever write runs first succeeds and the other fails.
Processors and storage controllers can make writes visible out of program order; a model that assumes program order checks a different system from the real one.
Switching the reduction on with an unchecked independence relation can hide exactly the interleaving or crash point under investigation.
The reduction saves little when most actions are dependent, as when every task updates one shared counter.
Questions answered
Can two writes to different records always commute?
No. Two writes to different records commute, meaning that both orders are possible and end in the same state, only when they share no state in the model and neither write enables or disables the other. Different records can share a hidden log position, an erase block of flash memory, a free-space limit or a checksum, and a capacity limit can let one write prevent the other.
Even when both orders end in the same state, they pass through different intermediate states: new with old , or old with new . A property such as “selector announces only a complete record ”, an observer that reads between the writes, or a crash between them can tell these apart. Partial-order reduction, which lets a model checker explore one order of independent actions instead of all, may skip the second order only if the writes are independent and invisible to the property, and only if crashes and observers are modeled as actions, so that the reduction’s conditions keep every order they can distinguish.
Related entries: State explosion (§3.26), Model checking (§3.30), Race condition (§9.2). Further reading: [439, 524].