-
Notifications
You must be signed in to change notification settings - Fork 44
Profiteur timing visualisation #3951
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
Changes from 15 commits
91c4410
b33b5f3
adb6edd
8da0b3b
f632743
f963c06
fb616af
39737e9
967a74b
94c74ca
816c388
d0a2df4
0b85265
de1a64e
83eab8a
5ad2745
9a2f0de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,8 @@ allowedLogLevels = | |
( "EquationWarnings" | ||
, "Log warnings indicating soft-violations of conditions, i.e. exceeding the equation recursion/iteration limit " | ||
) | ||
, ("Timing", "Logs for timing analysis") | ||
, ("TimingStats", "Formerly --print-stats") | ||
] | ||
|
||
levelToContext :: Map Text [ContextFilter] | ||
|
@@ -244,49 +246,64 @@ levelToContext = | |
[ | ||
( "Simplify" | ||
, | ||
[ [ctxt| booster|kore>function*|simplification*|hook*,success|failure|abort|detail |] | ||
, [ctxt| booster|kore>function*|simplification*,match,failure|abort |] | ||
[ [ctxt| request*,booster|kore>function*|simplification*|hook*,success|failure|abort|detail |] | ||
, [ctxt| request*,booster|kore>function*|simplification*,match,failure|abort |] | ||
] | ||
) | ||
, | ||
( "SimplifySuccess" | ||
, | ||
[ [ctxt| booster|kore>function*|simplification*|hook*,success|detail |] | ||
[ [ctxt| request*,booster|kore>function*|simplification*|hook*,success|detail |] | ||
] | ||
) | ||
, | ||
( "Rewrite" | ||
, | ||
[ [ctxt| booster|kore>rewrite*,success|failure|abort|detail |] | ||
, [ctxt| booster|kore>rewrite*,match|definedness|constraint,failure|abort |] | ||
[ [ctxt| request*,booster|kore>rewrite*,success|failure|abort|detail |] | ||
, [ctxt| request*,booster|kore>rewrite*,match|definedness|constraint,failure|abort |] | ||
] | ||
) | ||
, | ||
( "RewriteSuccess" | ||
, | ||
[ [ctxt| booster|kore>rewrite*,success|detail |] | ||
[ [ctxt| request*,booster|kore>rewrite*,success|detail |] | ||
] | ||
) | ||
, | ||
( "SMT" | ||
, | ||
[ [ctxt| booster|kore>smt |] | ||
[ [ctxt| request*,booster|kore>smt |] | ||
] | ||
) | ||
, | ||
( "Aborts" | ||
, | ||
[ [ctxt| booster>rewrite*,detail. |] | ||
, [ctxt| booster>rewrite*,match|definedness|constraint,abort. |] | ||
[ [ctxt| request*,booster>rewrite*,detail. |] | ||
, [ctxt| request*,booster>rewrite*,match|definedness|constraint,abort. |] | ||
, [ctxt| proxy. |] | ||
, [ctxt| proxy,abort. |] | ||
, [ctxt| booster>failure,abort |] | ||
, [ctxt| request*,booster>failure,abort |] | ||
] | ||
) | ||
, | ||
( "EquationWarnings" | ||
, | ||
[ [ctxt| booster>(simplification *|function *)>warning |] | ||
[ [ctxt| request*,booster>(simplification *|function *)>warning |] | ||
] | ||
) | ||
, | ||
( "Timing" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag could also include what is currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code to parse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW |
||
, | ||
[ [ctxt| request*,booster|kore>rewrite*,success|failure|abort|detail |] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to distinguish requests easily, I've added a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see why you need this ... wanted to suggest adding the ID to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we already have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i just noticed we no longer have the ceil context, @jberthold what was the reason for removing it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned, the |
||
, [ctxt| request*,booster|kore>rewrite*,match|definedness|condition,failure|abort |] | ||
, [ctxt| request*,booster|kore>function*|simplification*,success|failure|abort|detail |] | ||
, [ctxt| request*,booster|kore>function*|simplification*,match,failure|abort |] | ||
] | ||
) | ||
, | ||
( "TimingStats" | ||
, | ||
[ [ctxt| *>timing |] | ||
] | ||
) | ||
] | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{- | Stand-alone parser executable for extracting timing information from JSON context logs | ||
|
||
Copyright : (c) Runtime Verification, 2022 | ||
License : BSD-3-Clause | ||
-} | ||
module Main ( | ||
main, | ||
) where | ||
|
||
import Data.Aeson (decode) | ||
import Data.ByteString.Lazy.Char8 qualified as BS | ||
import Data.Maybe (mapMaybe) | ||
import Profiteur | ||
import Profiteur.Main (writeReport) | ||
import System.Environment (getArgs) | ||
import System.IO qualified as IO | ||
|
||
{- | Utility for parsing and extracting timing information from context logs, | ||
produced by running the booster binary with `-l Timing --log-format json --log-timestamps --timestamp-format nanosecond`. | ||
This tool collects the timing per each context level and uses the profiteur library to generate an HTML report of the timing information | ||
Call via `timing <path>.log` | ||
-} | ||
main :: IO () | ||
main = | ||
getArgs >>= \case | ||
files | ||
| "-h" `elem` files || "--help" `elem` files -> do | ||
putStrLn | ||
"This tool parses the JSON contextual logs with timestamps and generates a time profile." | ||
putStrLn "Call via `time-profile <path>.log`" | ||
putStrLn | ||
"To produce the correct context logs, run kore-rpc-booster with `-l Timing --log-format json --log-timestamps --timestamp-format nanosecond`" | ||
[profFile] -> do | ||
logs <- mapMaybe decode . BS.lines <$> BS.readFile profFile | ||
|
||
let (timings, ruleMap) = case logs of | ||
m : ms -> collectTiming mempty m ms | ||
[] -> mempty | ||
timing = foldr (((<>)) . fmap (,Count 1) . computeTimes) (TimeMap mempty) timings | ||
htmlFile = profFile ++ ".html" | ||
IO.withBinaryFile htmlFile IO.WriteMode $ \h -> do | ||
-- produce a timing map mirroring the context levels, roughly: | ||
-- main -> request n -> kore|booster -> execute|simplify|implies -> term rid -> rewrite id|simplification id|equation id -> success|failure | ||
writeReport h profFile $ toNodeMap timing ruleMap | ||
|
||
let htmlAggregateFile = profFile ++ ".aggregate.html" | ||
IO.withBinaryFile htmlAggregateFile IO.WriteMode $ \h -> do | ||
writeReport h profFile $ | ||
-- produce an agregate profile of all the number and total time spent trying each rewrite rule. The structure is: | ||
-- main -> request n -> rewrite id -> kore|booster | ||
toNodeMap (aggregateRewriteRules aggregateRewriteRulesPerRequest timing) ruleMap | ||
|
||
let htmlAggregateFile2 = profFile ++ ".aggregate2.html" | ||
IO.withBinaryFile htmlAggregateFile2 IO.WriteMode $ \h -> do | ||
writeReport h profFile $ | ||
-- produce an agregate profile of all the number and total time spent trying each rewrite rule. The structure is: | ||
-- main -> request n -> kore|booster -> rewrite id | ||
toNodeMap (aggregateRewriteRules aggregateRewriteRulesPerRequest2 timing) ruleMap | ||
_ -> error "invalid arguments" |
Uh oh!
There was an error while loading. Please reload this page.