From 375b045f19ef906899b1fa9c781b14bba22c9737 Mon Sep 17 00:00:00 2001 From: Andrea Vezzosi Date: Wed, 18 Dec 2024 10:26:33 +0100 Subject: [PATCH] simulation: limit CPU/network chart to last 10 seconds --- simulation/src/LeiosProtocol/Short/VizSim.hs | 27 ++++++++++--------- .../src/LeiosProtocol/Short/VizSimP2P.hs | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/simulation/src/LeiosProtocol/Short/VizSim.hs b/simulation/src/LeiosProtocol/Short/VizSim.hs index 153da6e..6f11a2f 100644 --- a/simulation/src/LeiosProtocol/Short/VizSim.hs +++ b/simulation/src/LeiosProtocol/Short/VizSim.hs @@ -401,9 +401,9 @@ leiosSimVizModel = ) (vizMsgsInTransit vs) , vizMsgsAtNodeRecentQueue = - Map.map (recentPrune secondsAgo30) (vizMsgsAtNodeRecentQueue vs) + Map.map (recentPrune secondsAgo10) (vizMsgsAtNodeRecentQueue vs) , vizMsgsAtNodeRecentBuffer = - Map.map (recentPrune secondsAgo30) (vizMsgsAtNodeRecentBuffer vs) + Map.map (recentPrune secondsAgo10) (vizMsgsAtNodeRecentBuffer vs) , vizMsgsDiffusionLatency = Map.filter (\(_, _, t, _) -> t >= secondsAgo30) (vizMsgsDiffusionLatency vs) , ibDiffusionLatency = @@ -412,11 +412,17 @@ leiosSimVizModel = Map.filter (\(_, _, t, _) -> t >= secondsAgo30) (ebDiffusionLatency vs) , voteDiffusionLatency = Map.filter (\(_, _, t, _) -> t >= secondsAgo30) (voteDiffusionLatency vs) - , ibMsgs = pruneLeiosMsgsState now vs.ibMsgs - , ebMsgs = pruneLeiosMsgsState now vs.ebMsgs - , voteMsgs = pruneLeiosMsgsState now vs.voteMsgs + , ibMsgs = pruneLeiosMsgsState (secondsAgo10, now) vs.ibMsgs + , ebMsgs = pruneLeiosMsgsState (secondsAgo10, now) vs.ebMsgs + , voteMsgs = pruneLeiosMsgsState (secondsAgo10, now) vs.voteMsgs + , nodeCpuUsage = + Map.map + (`ILMap.intersecting` coerce (ClosedInterval secondsAgo10 now)) + vs.nodeCpuUsage } where + secondsAgo10 :: Time + secondsAgo10 = addTime (-10) now secondsAgo30 :: Time secondsAgo30 = addTime (-30) now @@ -490,19 +496,16 @@ accumLeiosMsgs now nid EnterState blk vs = pruneLeiosMsgsState :: (Eq id, HasField "id" msg id) => - Time -> + (Time, Time) -> LeiosSimVizMsgsState id msg -> LeiosSimVizMsgsState id msg -pruneLeiosMsgsState now vs = +pruneLeiosMsgsState (ago, _now) vs = vs { msgsAtNodeRecentQueue = - Map.map (recentPrune secondsAgo30) (msgsAtNodeRecentQueue vs) + Map.map (recentPrune ago) (msgsAtNodeRecentQueue vs) , msgsAtNodeRecentBuffer = - Map.map (recentPrune secondsAgo30) (msgsAtNodeRecentBuffer vs) + Map.map (recentPrune ago) (msgsAtNodeRecentBuffer vs) } - where - secondsAgo30 :: Time - secondsAgo30 = addTime (-30) now accumIBsInRBs :: Either RankingBlock EndorseBlock -> IBsInRBsState -> IBsInRBsState accumIBsInRBs (Left rb) s = s{ebsInRBs = Map.insertWith Set.union (blockHash rb) (Set.fromList $ map fst rb.blockBody.endorseBlocks) s.ebsInRBs} diff --git a/simulation/src/LeiosProtocol/Short/VizSimP2P.hs b/simulation/src/LeiosProtocol/Short/VizSimP2P.hs index 5ef105f..4ce8d91 100644 --- a/simulation/src/LeiosProtocol/Short/VizSimP2P.hs +++ b/simulation/src/LeiosProtocol/Short/VizSimP2P.hs @@ -492,7 +492,7 @@ chartBandwidth = Chart.def { Chart._laxis_generate = Chart.scaledAxis Chart.def{Chart._la_nLabels = maxX} (0, maxX) - , Chart._laxis_title = "Count of events within last 30 seconds" + , Chart._laxis_title = "Count of events within last 10 seconds" } , Chart._layout_y_axis = Chart.def