make stats measurement delay configurable, take speedup into account
This commit is contained in:
parent
8f917130c4
commit
34ecdd66e1
|
@ -73,6 +73,8 @@ readConfig = do
|
||||||
, confServicePort = read servicePortString
|
, confServicePort = read servicePortString
|
||||||
, confServiceHost = confDomainString
|
, confServiceHost = confDomainString
|
||||||
, confLogfilePath = "../simulationData/logs/" <> confDomainString <> ".log"
|
, confLogfilePath = "../simulationData/logs/" <> confDomainString <> ".log"
|
||||||
|
, confSpeedupFactor = speedup
|
||||||
|
, confStatsEvalDelay = 35 * 10^6 `div` speedup
|
||||||
}
|
}
|
||||||
pure (fConf, sConf)
|
pure (fConf, sConf)
|
||||||
|
|
||||||
|
|
|
@ -459,6 +459,10 @@ data ServiceConf = ServiceConf
|
||||||
-- ^ hostname of service
|
-- ^ hostname of service
|
||||||
, confLogfilePath :: String
|
, confLogfilePath :: String
|
||||||
-- ^ where to store the (measurement) log file
|
-- ^ where to store the (measurement) log file
|
||||||
|
, confStatsEvalDelay :: Int
|
||||||
|
-- ^ delay between statistic rate measurement samplings, in microseconds
|
||||||
|
, confSpeedupFactor :: Int
|
||||||
|
-- While the speedup factor needs to be already included in all
|
||||||
}
|
}
|
||||||
|
|
||||||
class DHT d where
|
class DHT d where
|
||||||
|
|
|
@ -743,9 +743,6 @@ data RelayStats = RelayStats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- TODO: make delay configurable
|
|
||||||
statsEvalDelay = 300000
|
|
||||||
|
|
||||||
|
|
||||||
launchStatsThreads :: PostService d -> IO ()
|
launchStatsThreads :: PostService d -> IO ()
|
||||||
launchStatsThreads serv = do
|
launchStatsThreads serv = do
|
||||||
|
@ -795,7 +792,7 @@ evaluateStatsThread :: PostService d -> TVar RelayStats -> IO ()
|
||||||
evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
|
evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
|
||||||
where
|
where
|
||||||
loop previousTs = do
|
loop previousTs = do
|
||||||
threadDelay statsEvalDelay
|
threadDelay $ confStatsEvalDelay (serviceConf serv)
|
||||||
-- get and reset the stats accumulator
|
-- get and reset the stats accumulator
|
||||||
summedStats <- atomically $ do
|
summedStats <- atomically $ do
|
||||||
stats <- readTVar statsAcc
|
stats <- readTVar statsAcc
|
||||||
|
@ -806,7 +803,8 @@ evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
|
||||||
now <- getPOSIXTime
|
now <- getPOSIXTime
|
||||||
-- 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
|
||||||
atomically . writeTVar (loadStats serv) . evaluateStats (now - previousTs) $ summedStats
|
let timePassed = (now - previousTs) * fromIntegral (confSpeedupFactor $ serviceConf serv)
|
||||||
|
atomically . writeTVar (loadStats serv) . evaluateStats timePassed $ summedStats
|
||||||
-- 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
|
||||||
|
@ -833,7 +831,6 @@ evaluateStats timeInterval summedStats =
|
||||||
, postFetchRate = postFetchRate summedStats / intervalSeconds
|
, postFetchRate = postFetchRate summedStats / intervalSeconds
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
-- TODO: take speedup into account
|
|
||||||
intervalSeconds = fromIntegral (fromEnum timeInterval) / 10^12
|
intervalSeconds = fromIntegral (fromEnum timeInterval) / 10^12
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue