File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ import Kore.Log
127127import Kore.Log.ErrorException
128128 ( errorException
129129 )
130+ import Kore.Log.WarnIfLowProductivity
131+ ( warnIfLowProductivity
132+ )
130133import qualified Kore.ModelChecker.Bounded as Bounded
131134 ( CheckResult (.. )
132135 )
@@ -573,7 +576,7 @@ mainWithOptions execOptions = do
573576 exitCode <-
574577 withBugReport Main. exeName bugReport $ \ tmpDir -> do
575578 writeOptionsAndKoreFiles tmpDir execOptions
576- go
579+ go <* warnIfLowProductivity
577580 & handle handleWithConfiguration
578581 & handle handleSomeException
579582 & runKoreLog tmpDir koreLogOptions
Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ import Kore.Log
5656import Kore.Log.KoreLogOptions
5757 ( parseKoreLogOptions
5858 )
59+ import Kore.Log.WarnIfLowProductivity
60+ ( warnIfLowProductivity
61+ )
5962import Kore.Repl.Data
6063import Kore.Step.SMT.Lemma
6164import Kore.Syntax.Module
@@ -271,6 +274,7 @@ mainWithOptions
271274 mainModuleName
272275 koreLogOptions
273276
277+ warnIfLowProductivity
274278 pure ExitSuccess
275279 exitWith exitCode
276280 where
Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ import Kore.Log.InfoReachability
9595import Kore.Log.WarnFunctionWithoutEvaluators
9696 ( WarnFunctionWithoutEvaluators
9797 )
98+ import Kore.Log.WarnIfLowProductivity
99+ ( WarnIfLowProductivity
100+ )
98101import Kore.Log.WarnStuckProofState
99102 ( WarnStuckProofState
100103 )
@@ -148,6 +151,7 @@ entryHelpDocs :: [Pretty.Doc ()]
148151 , mk $ Proxy @ WarnFunctionWithoutEvaluators
149152 , mk $ Proxy @ WarnSymbolSMTRepresentation
150153 , mk $ Proxy @ WarnStuckProofState
154+ , mk $ Proxy @ WarnIfLowProductivity
151155 , mk $ Proxy @ DebugEvaluateCondition
152156 , mk $ Proxy @ ErrorException
153157 , mk $ Proxy @ ErrorRewriteLoop
Original file line number Diff line number Diff line change 1+ {- |
2+ Copyright : (c) Runtime Verification, 2020
3+ License : NCSA
4+
5+ -}
6+
7+ module Kore.Log.WarnIfLowProductivity
8+ ( WarnIfLowProductivity (.. )
9+ , warnIfLowProductivity
10+ )where
11+
12+ import Prelude.Kore
13+
14+ import Log
15+ import Numeric.Natural
16+ import Pretty
17+ ( Pretty
18+ )
19+ import qualified Pretty
20+ import Stats
21+
22+ newtype WarnIfLowProductivity =
23+ WarnIfLowProductivity { productivityPercent :: Natural }
24+ deriving Show
25+
26+ instance Pretty WarnIfLowProductivity where
27+ pretty (WarnIfLowProductivity productivityPercent) =
28+ Pretty. hsep
29+ [ " Warning! Poor performance: productivity dropped to aprox."
30+ , Pretty. pretty productivityPercent <> " %"
31+ ]
32+
33+ instance Entry WarnIfLowProductivity where
34+ entrySeverity _ = Warning
35+ helpDoc _ = " warn when productivty (MUT time / Total time) drops below 90%"
36+
37+ warnIfLowProductivity :: MonadLog log => MonadIO log => log ()
38+ warnIfLowProductivity = do
39+ Stats { gc_cpu_ns, cpu_ns } <- liftIO getStats
40+ let gcTimeOver10Percent = gc_cpu_ns * 10 > cpu_ns
41+ gcPercentage = gc_cpu_ns * 100 `div` cpu_ns
42+ productivity = 100 - gcPercentage & fromIntegral
43+ when gcTimeOver10Percent . logEntry
44+ $ WarnIfLowProductivity productivity
You can’t perform that action at this time.
0 commit comments