strict timeline tail

This commit is contained in:
Alexander Bondarenko
2024-06-17 11:41:11 +03:00
parent dcb8e33ccb
commit 76bd21e086
+3 -1
View File
@@ -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)