diff --git a/app/Main.hs b/app/Main.hs index 80c0520..a620fe8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -73,6 +73,8 @@ readConfig = do , confServicePort = read servicePortString , confServiceHost = confDomainString , confLogfilePath = "../simulationData/logs/" <> confDomainString <> ".log" + , confSpeedupFactor = speedup + , confStatsEvalDelay = 35 * 10^6 `div` speedup } pure (fConf, sConf) diff --git a/src/Hash2Pub/FediChordTypes.hs b/src/Hash2Pub/FediChordTypes.hs index 725031e..4ce20a7 100644 --- a/src/Hash2Pub/FediChordTypes.hs +++ b/src/Hash2Pub/FediChordTypes.hs @@ -459,6 +459,10 @@ data ServiceConf = ServiceConf -- ^ hostname of service , confLogfilePath :: String -- ^ 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 diff --git a/src/Hash2Pub/PostService.hs b/src/Hash2Pub/PostService.hs index 7a082d0..d3e7daf 100644 --- a/src/Hash2Pub/PostService.hs +++ b/src/Hash2Pub/PostService.hs @@ -743,9 +743,6 @@ data RelayStats = RelayStats } --- TODO: make delay configurable -statsEvalDelay = 300000 - launchStatsThreads :: PostService d -> IO () launchStatsThreads serv = do @@ -795,7 +792,7 @@ evaluateStatsThread :: PostService d -> TVar RelayStats -> IO () evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop where loop previousTs = do - threadDelay statsEvalDelay + threadDelay $ confStatsEvalDelay (serviceConf serv) -- get and reset the stats accumulator summedStats <- atomically $ do stats <- readTVar statsAcc @@ -806,7 +803,8 @@ evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop now <- getPOSIXTime -- evaluate stats rate and replace server stats -- 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 -- format: total relayReceiveRates;total relayDeliveryRates;postFetchRate;postPublishRate -- later: current (reported) load, target load @@ -833,7 +831,6 @@ evaluateStats timeInterval summedStats = , postFetchRate = postFetchRate summedStats / intervalSeconds } where - -- TODO: take speedup into account intervalSeconds = fromIntegral (fromEnum timeInterval) / 10^12