Skip to content

Commit a045a32

Browse files
authored
Do not keep execution graph in memory (#1804)
1 parent da71a9b commit a045a32

File tree

11 files changed

+317
-151
lines changed

11 files changed

+317
-151
lines changed

kore/src/Kore/Exec.hs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Control.Error.Util
3030
)
3131
import Control.Monad.Catch
3232
( MonadCatch
33+
, MonadThrow
3334
)
3435
import Control.Monad.Trans.Except
3536
( runExceptT
@@ -167,6 +168,9 @@ import Kore.Unparser
167168
( unparseToText
168169
, unparseToText2
169170
)
171+
import Log
172+
( MonadLog
173+
)
170174
import qualified Log
171175
import SMT
172176
( MonadSMT
@@ -197,10 +201,11 @@ data Execution =
197201

198202
-- | Symbolic execution
199203
exec
200-
:: ( Log.WithLog Log.LogMessage smt
204+
:: ( MonadIO smt
205+
, MonadLog smt
201206
, MonadProfiler smt
202207
, MonadSMT smt
203-
, MonadIO smt
208+
, MonadThrow smt
204209
)
205210
=> Limit Natural
206211
-> VerifiedModule StepperAttributes
@@ -234,10 +239,11 @@ exec breadthLimit verifiedModule strategy initialTerm =
234239

235240
-- | Project the value of the exit cell, if it is present.
236241
execGetExitCode
237-
:: ( Log.WithLog Log.LogMessage smt
242+
:: ( MonadIO smt
243+
, MonadLog smt
238244
, MonadProfiler smt
239245
, MonadSMT smt
240-
, MonadIO smt
246+
, MonadThrow smt
241247
)
242248
=> VerifiedModule StepperAttributes
243249
-- ^ The main module
@@ -262,10 +268,11 @@ execGetExitCode indexedModule strategy' finalTerm =
262268

263269
-- | Symbolic search
264270
search
265-
:: ( Log.WithLog Log.LogMessage smt
271+
:: ( MonadIO smt
272+
, MonadLog smt
266273
, MonadProfiler smt
267274
, MonadSMT smt
268-
, MonadIO smt
275+
, MonadThrow smt
269276
)
270277
=> Limit Natural
271278
-> VerifiedModule StepperAttributes
@@ -404,6 +411,7 @@ boundedModelCheck
404411
, MonadProfiler smt
405412
, MonadSMT smt
406413
, MonadIO smt
414+
, MonadThrow smt
407415
)
408416
=> Limit Natural
409417
-> Limit Natural
@@ -584,7 +592,7 @@ simplifyReachabilityRule rule = do
584592

585593
-- | Construct an execution graph for the given input pattern.
586594
execute
587-
:: MonadSimplify simplifier
595+
:: (MonadSimplify simplifier, MonadThrow simplifier)
588596
=> Limit Natural
589597
-> VerifiedModule StepperAttributes
590598
-- ^ The main module

kore/src/Kore/ModelChecker/Bounded.hs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ module Kore.ModelChecker.Bounded
1414

1515
import Prelude.Kore
1616

17+
import Control.Monad.Catch
18+
( MonadThrow
19+
)
1720
import qualified Control.Monad.State.Strict as State
1821
import qualified Data.Foldable as Foldable
1922
import qualified Data.Graph.Inductive.Graph as Graph
@@ -100,7 +103,7 @@ bmcStrategy
100103

101104
checkClaim
102105
:: forall m
103-
. MonadSimplify m
106+
. (MonadSimplify m, MonadThrow m)
104107
=> Limit Natural
105108
-> ( CommonModalPattern
106109
-> [Strategy (Prim CommonModalPattern (RewriteRule Variable))]
@@ -133,14 +136,14 @@ checkClaim
133136
, predicate = Predicate.makeTruePredicate_
134137
, substitution = mempty
135138
}
136-
executionGraph <- State.evalStateT
137-
(runStrategyWithSearchOrder
138-
breadthLimit
139-
transitionRule'
140-
strategy
141-
searchOrder
142-
startState)
143-
Nothing
139+
executionGraph <-
140+
runStrategyWithSearchOrder
141+
breadthLimit
142+
transitionRule'
143+
strategy
144+
searchOrder
145+
startState
146+
& flip State.evalStateT Nothing
144147

145148
Log.logInfo . Text.pack
146149
$ ("searched states: " ++ (show . Graph.order . graph $ executionGraph))

kore/src/Kore/Profiler/Data.hs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import Prelude.Kore
1717
import Control.Monad
1818
( when
1919
)
20+
import Control.Monad.Catch.Pure
21+
( CatchT
22+
, mapCatchT
23+
)
2024
import Control.Monad.Morph
2125
( MFunctor (..)
2226
)
@@ -25,8 +29,8 @@ import Control.Monad.Reader
2529
)
2630
import qualified Control.Monad.State.Strict as Strict
2731
import Control.Monad.Trans.Accum
28-
( AccumT (AccumT)
29-
, runAccumT
32+
( AccumT
33+
, mapAccumT
3034
)
3135
import Control.Monad.Trans.Except
3236
( ExceptT
@@ -55,12 +59,10 @@ import System.Clock
5559
import Control.Monad.Counter
5660
import ListT
5761
( ListT (..)
58-
)
59-
import qualified ListT
60-
( mapListT
62+
, mapListT
6163
)
6264

63-
{- Monad that can also handle profiling events.
65+
{- | Monad that can also handle profiling events.
6466
-}
6567
class Monad profiler => MonadProfiler profiler where
6668
profile
@@ -257,24 +259,27 @@ profileGhcEventsAnalyze event action = do
257259
liftIO $ traceEventIO ("STOP " ++ List.intercalate "/" event)
258260
return a
259261

260-
instance (MonadProfiler m) => MonadProfiler (ReaderT thing m )
261-
262-
instance MonadProfiler m => MonadProfiler (Strict.StateT s m)
262+
instance (MonadProfiler m, Monoid w) => MonadProfiler (AccumT w m)
263+
where
264+
profile a = mapAccumT (profile a)
265+
{-# INLINE profile #-}
263266

264-
instance MonadProfiler m => MonadProfiler (MaybeT m)
267+
instance MonadProfiler m => MonadProfiler (CatchT m) where
268+
profile a = mapCatchT (profile a)
269+
{-# INLINE profile #-}
265270

266-
instance MonadProfiler m => MonadProfiler (IdentityT m)
271+
instance MonadProfiler m => MonadProfiler (CounterT m)
267272

268273
instance MonadProfiler m => MonadProfiler (ExceptT e m)
269274

275+
instance MonadProfiler m => MonadProfiler (IdentityT m)
276+
270277
instance MonadProfiler m => MonadProfiler (ListT m) where
271-
profile a action =
272-
ListT.mapListT (profile a) action
278+
profile a = mapListT (profile a)
273279
{-# INLINE profile #-}
274280

275-
instance (MonadProfiler m, Monoid w) => MonadProfiler (AccumT w m)
276-
where
277-
profile a action = AccumT (profile a . runAccumT action)
278-
{-# INLINE profile #-}
281+
instance MonadProfiler m => MonadProfiler (MaybeT m)
279282

280-
instance MonadProfiler m => MonadProfiler (CounterT m)
283+
instance MonadProfiler m => MonadProfiler (ReaderT thing m )
284+
285+
instance MonadProfiler m => MonadProfiler (Strict.StateT s m)

kore/src/Kore/Profiler/Profile.hs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,7 @@ smtDecision (sexpr :| _) action = do
237237
then profile ["SMT", show $ length $ show sexpr] action
238238
else action
239239

240-
executionQueueLength
241-
:: MonadProfiler profiler
242-
=> Int -> profiler result -> profiler result
243-
executionQueueLength len action = do
244-
Configuration {logStrategy} <- profileConfiguration
245-
when logStrategy
246-
(profileValue ["ExecutionQueueLength"] len)
247-
action
240+
executionQueueLength :: MonadProfiler profiler => Int -> profiler ()
241+
executionQueueLength len = do
242+
Configuration { logStrategy } <- profileConfiguration
243+
when logStrategy (profileValue ["ExecutionQueueLength"] len)

kore/src/Kore/Step.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ import qualified Kore.Step.SMT.Evaluator as SMT.Evaluator
6161
( filterMultiOr
6262
)
6363
import qualified Kore.Step.Step as Step
64-
import Kore.Step.Strategy
64+
import Kore.Step.Strategy hiding
65+
( transitionRule
66+
)
6567
import qualified Kore.Step.Strategy as Strategy
6668
import qualified Kore.Step.Transition as Transition
6769
import Kore.Syntax.Variable

0 commit comments

Comments
 (0)