log the post rates instead of the absolute sums

This commit is contained in:
Trolli Schmittlauch 2020-09-10 22:40:56 +02:00
parent 34ecdd66e1
commit 0f9727c05a

View file

@ -44,6 +44,7 @@ import Hash2Pub.PostService.API
import Hash2Pub.RingMap
import Hash2Pub.Utils
import Debug.Trace
data PostService d = PostService
{ serviceConf :: ServiceConf
@ -727,6 +728,7 @@ data StatsEventType = PostPublishEvent
-- | Represents measurement event of a 'StatsEventType' with a count relevant for a certain key
data StatsEvent = StatsEvent StatsEventType Int NodeID
deriving (Show, Eq)
-- | measured rates of relay performance
@ -741,6 +743,7 @@ data RelayStats = RelayStats
, postPublishRate :: Double
-- ^ rate of initially publishing posts through this instance
}
deriving (Show, Eq)
@ -804,7 +807,8 @@ evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
-- evaluate stats rate and replace server stats
-- persistently store in a TVar so it can be retrieved later by the DHT
let timePassed = (now - previousTs) * fromIntegral (confSpeedupFactor $ serviceConf serv)
atomically . writeTVar (loadStats serv) . evaluateStats timePassed $ summedStats
let rateStats = evaluateStats timePassed summedStats
atomically $ writeTVar (loadStats serv) rateStats
-- and now what? write a log to file
-- format: total relayReceiveRates;total relayDeliveryRates;postFetchRate;postPublishRate
-- later: current (reported) load, target load
@ -814,7 +818,7 @@ evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
, show . sum . relayDeliveryRates
, show . postPublishRate
, show . postFetchRate
] <*> pure summedStats)) <> "\n"
] <*> pure rateStats)) <> "\n"
loop now
@ -831,7 +835,7 @@ evaluateStats timeInterval summedStats =
, postFetchRate = postFetchRate summedStats / intervalSeconds
}
where
intervalSeconds = fromIntegral (fromEnum timeInterval) / 10^12
intervalSeconds = realToFrac timeInterval
emptyStats :: RelayStats