Skip to content

Commit 7103b11

Browse files
committed
io-sim-por: make updateRaces and normalizeRaces more strict
1 parent 2c50afe commit 7103b11

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

io-sim/src/Control/Monad/IOSimPOR/Internal.hs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,30 +1466,30 @@ updateRaces newStep@Step{ stepThreadId = tid, stepEffect = newEffect }
14661466

14671467
-- a new step cannot race with any threads that it just woke up
14681468
new :: [StepInfo]
1469-
new | isNotRacyThreadId tid = [] -- non-racy threads do not race
1470-
| Set.null newConcurrent = [] -- cannot race with anything
1471-
| justBlocking = [] -- no need to defer a blocking transaction
1472-
| otherwise =
1473-
[StepInfo { stepInfoStep = newStep,
1474-
stepInfoControl = control,
1475-
stepInfoConcurrent = newConcurrent,
1476-
stepInfoNonDep = [],
1477-
stepInfoRaces = []
1478-
}]
1469+
!new | isNotRacyThreadId tid = [] -- non-racy threads do not race
1470+
| Set.null newConcurrent = [] -- cannot race with anything
1471+
| justBlocking = [] -- no need to defer a blocking transaction
1472+
| otherwise =
1473+
[StepInfo { stepInfoStep = newStep,
1474+
stepInfoControl = control,
1475+
stepInfoConcurrent = newConcurrent,
1476+
stepInfoNonDep = [],
1477+
stepInfoRaces = []
1478+
}]
14791479
where
14801480
newConcurrent :: Set ThreadId
14811481
newConcurrent = foldr Set.delete newConcurrent0 (effectWakeup newEffect)
14821482

14831483
activeRaces' :: [StepInfo]
1484-
activeRaces' =
1484+
!activeRaces' =
14851485
[ -- if this step depends on the previous step, or is not concurrent,
14861486
-- then any threads that it wakes up become non-concurrent also.
1487-
let lessConcurrent = foldr Set.delete concurrent (effectWakeup newEffect) in
1487+
let !lessConcurrent = foldr Set.delete concurrent (effectWakeup newEffect) in
14881488
if tid `elem` concurrent then
14891489
let theseStepsRace = isRacyThreadId tid && racingSteps step newStep
14901490
happensBefore = step `happensBeforeStep` newStep
1491-
nondep' | happensBefore = nondep
1492-
| otherwise = newStep : nondep
1491+
!nondep' | happensBefore = nondep
1492+
| otherwise = newStep : nondep
14931493
-- We will only record the first race with each thread---reversing
14941494
-- the first race makes the next race detectable. Thus we remove a
14951495
-- thread from the concurrent set after the first race.
@@ -1499,10 +1499,10 @@ updateRaces newStep@Step{ stepThreadId = tid, stepEffect = newEffect }
14991499
-- Here we record discovered races.
15001500
-- We only record a new race if we are following the default schedule,
15011501
-- to avoid finding the same race in different parts of the search space.
1502-
stepRaces' | (control == ControlDefault ||
1503-
control == ControlFollow [] []) &&
1504-
theseStepsRace = newStep : stepRaces
1505-
| otherwise = stepRaces
1502+
!stepRaces' | (control == ControlDefault ||
1503+
control == ControlFollow [] []) &&
1504+
theseStepsRace = newStep : stepRaces
1505+
| otherwise = stepRaces
15061506

15071507
in stepInfo { stepInfoConcurrent = effectForks newEffect
15081508
`Set.union` concurrent',
@@ -1512,10 +1512,10 @@ updateRaces newStep@Step{ stepThreadId = tid, stepEffect = newEffect }
15121512

15131513
else stepInfo { stepInfoConcurrent = lessConcurrent }
15141514

1515-
| stepInfo@StepInfo { stepInfoStep = step,
1516-
stepInfoConcurrent = concurrent,
1517-
stepInfoNonDep = nondep,
1518-
stepInfoRaces = stepRaces
1515+
| !stepInfo@StepInfo { stepInfoStep = step,
1516+
stepInfoConcurrent = concurrent,
1517+
stepInfoNonDep = nondep,
1518+
stepInfoRaces = stepRaces
15191519
}
15201520
<- activeRaces ]
15211521
in normalizeRaces $ races { activeRaces = new ++ activeRaces' }
@@ -1531,10 +1531,10 @@ threadTerminatesRaces tid races@Races{ activeRaces } =
15311531

15321532
normalizeRaces :: Races -> Races
15331533
normalizeRaces Races{ activeRaces, completeRaces } =
1534-
let activeRaces' = filter (not . null. stepInfoConcurrent) activeRaces
1535-
completeRaces' = filter (not . null. stepInfoRaces)
1536-
(filter (null . stepInfoConcurrent) activeRaces)
1537-
++ completeRaces
1534+
let !activeRaces' = filter (not . null. stepInfoConcurrent) activeRaces
1535+
!completeRaces' = filter (not . null. stepInfoRaces)
1536+
(filter (null . stepInfoConcurrent) activeRaces)
1537+
++ completeRaces
15381538
in Races{ activeRaces = activeRaces', completeRaces = completeRaces' }
15391539

15401540
-- We assume that steps do not race with later steps after a quiescent

0 commit comments

Comments
 (0)