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