From 76bd21e086c15f09cb5be466e1b68ee7e69284a0 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:41:11 +0300 Subject: [PATCH] strict timeline tail --- src/Simplex/Messaging/Server.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Messaging/Server.hs b/src/Simplex/Messaging/Server.hs index 605c0f837..9b7433471 100644 --- a/src/Simplex/Messaging/Server.hs +++ b/src/Simplex/Messaging/Server.hs @@ -329,7 +329,9 @@ smpServer started cfg@ServerConfig {transports, transportConfig = tCfg} = do threadDelay' $ bucketWidth * 1000000 stats <- readTVarIO stats' >>= mapM (CS.readClientStatsData readTVarIO) let !rates = distribution . histogram <$> collect stats - atomically . modifyTVar' rates' $ (rates :) . take nBuckets + atomically . modifyTVar' rates' $ \old -> + let timeline = take nBuckets old + in length timeline `seq` rates : timeline where collect :: IntMap CS.ClientStatsData -> CS.ClientStatsC (IntMap Int) collect = IM.foldlWithKey' toColumns (CS.clientStatsC IM.empty)