Skip to content

Trace rewrites #2339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions kore/src/Kore/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ import Kore.Step.Search
)
import qualified Kore.Step.Search as Search
import Kore.Step.Simplification.Data
( MonadProf
, evalSimplifier
( evalSimplifier
)
import qualified Kore.Step.Simplification.Data as Simplifier
import qualified Kore.Step.Simplification.Pattern as Pattern
Expand All @@ -168,6 +167,7 @@ import Kore.Step.Simplification.Simplify
import qualified Kore.Step.Strategy as Strategy
import Kore.Step.Transition
( runTransitionT
, scatter
)
import Kore.Syntax.Module
( ModuleName
Expand All @@ -185,6 +185,7 @@ import Logic
, observeAllT
)
import qualified Logic
import Prof
import SMT
( MonadSMT
, SMT
Expand Down Expand Up @@ -236,7 +237,9 @@ exec depthLimit breadthLimit verifiedModule strategy initialTerm =
rewriteGroups = groupRewritesByPriority rewriteRules
transit instr config =
Strategy.transitionRule
(transitionRule rewriteGroups strategy & trackExecDepth)
(transitionRule rewriteGroups strategy
& profTransitionRule
& trackExecDepth)
instr
config
& runTransitionT
Expand Down Expand Up @@ -287,6 +290,24 @@ trackExecDepth transit prim (execDepth, execState) = do
isRewrite Rewrite = True
isRewrite _ = False

{- | Add profiling markers to a 'TransitionRule'.
-}
profTransitionRule
:: forall monad rule state
. MonadProf monad
=> TransitionRule monad rule state
-> TransitionRule monad rule state
profTransitionRule rule prim proofState =
case prim of
Rewrite -> Just ":rewrite:"
Simplify -> Just ":simplify:"
Begin -> Nothing
& \case
Just marker -> lift (traceProf marker (runTransitionT go)) >>= scatter
Nothing -> go
where
go = rule prim proofState

-- | Project the value of the exit cell, if it is present.
getExitCode
:: forall simplifier
Expand Down Expand Up @@ -365,7 +386,8 @@ search depthLimit breadthLimit verifiedModule termLike searchPattern searchConfi
breadthLimit
-- search relies on exploring
-- the entire space of states.
(transitionRule rewriteGroups All)
(transitionRule rewriteGroups All
& profTransitionRule)
(limitedExecutionStrategy depthLimit)
executionGraph <-
runStrategy' (Start $ mkRewritingPattern initialPattern)
Expand Down