Skip to content

Commit d8510a0

Browse files
authored
Trace rewrites (#2339)
Fixes #2331 - Adding new `profTransitionRule` rule, analogous to `Kore.Reachability.Prove.profTransitionRule`, which adds profile tracing for rewrites. - Wrapping two invocations of `transitionRule` in `Kore.Exec` with this new function. --- ###### Review checklist The author performs the actions on the checklist. The reviewer evaluates the work and checks the boxes as they are completed. - [x] **Summary.** Write a summary of the changes. Explain what you did to fix the issue, and why you did it. Present the changes in a logical order. Instead of writing a summary in the pull request, you may push a clean Git history. - [x] **Documentation.** Write documentation for new functions. Update documentation for functions that changed, or complete documentation where it is missing. - [ ] **Tests.** Write unit tests for every change. Write the unit tests that were missing before the changes. Include any examples from the reported issue as integration tests. - [x] **Clean up.** The changes are already clean. Clean up anything near the changes that you noticed while working. This does not mean only spatially near the changes, but logically near: any code that interacts with the changes!
1 parent eb384ef commit d8510a0

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

kore/src/Kore/Exec.hs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ import Kore.Step.Search
156156
)
157157
import qualified Kore.Step.Search as Search
158158
import Kore.Step.Simplification.Data
159-
( MonadProf
160-
, evalSimplifier
159+
( evalSimplifier
161160
)
162161
import qualified Kore.Step.Simplification.Data as Simplifier
163162
import qualified Kore.Step.Simplification.Pattern as Pattern
@@ -168,6 +167,7 @@ import Kore.Step.Simplification.Simplify
168167
import qualified Kore.Step.Strategy as Strategy
169168
import Kore.Step.Transition
170169
( runTransitionT
170+
, scatter
171171
)
172172
import Kore.Syntax.Module
173173
( ModuleName
@@ -185,6 +185,7 @@ import Logic
185185
, observeAllT
186186
)
187187
import qualified Logic
188+
import Prof
188189
import SMT
189190
( MonadSMT
190191
, SMT
@@ -236,7 +237,9 @@ exec depthLimit breadthLimit verifiedModule strategy initialTerm =
236237
rewriteGroups = groupRewritesByPriority rewriteRules
237238
transit instr config =
238239
Strategy.transitionRule
239-
(transitionRule rewriteGroups strategy & trackExecDepth)
240+
(transitionRule rewriteGroups strategy
241+
& profTransitionRule
242+
& trackExecDepth)
240243
instr
241244
config
242245
& runTransitionT
@@ -287,6 +290,24 @@ trackExecDepth transit prim (execDepth, execState) = do
287290
isRewrite Rewrite = True
288291
isRewrite _ = False
289292

293+
{- | Add profiling markers to a 'TransitionRule'.
294+
-}
295+
profTransitionRule
296+
:: forall monad rule state
297+
. MonadProf monad
298+
=> TransitionRule monad rule state
299+
-> TransitionRule monad rule state
300+
profTransitionRule rule prim proofState =
301+
case prim of
302+
Rewrite -> Just ":rewrite:"
303+
Simplify -> Just ":simplify:"
304+
Begin -> Nothing
305+
& \case
306+
Just marker -> lift (traceProf marker (runTransitionT go)) >>= scatter
307+
Nothing -> go
308+
where
309+
go = rule prim proofState
310+
290311
-- | Project the value of the exit cell, if it is present.
291312
getExitCode
292313
:: forall simplifier
@@ -365,7 +386,8 @@ search depthLimit breadthLimit verifiedModule termLike searchPattern searchConfi
365386
breadthLimit
366387
-- search relies on exploring
367388
-- the entire space of states.
368-
(transitionRule rewriteGroups All)
389+
(transitionRule rewriteGroups All
390+
& profTransitionRule)
369391
(limitedExecutionStrategy depthLimit)
370392
executionGraph <-
371393
runStrategy' (Start $ mkRewritingPattern initialPattern)

0 commit comments

Comments
 (0)