Skip to content

Commit

Permalink
feat(sut): msync metadata and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Mar 11, 2022
1 parent 98d9a89 commit 4221557
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/journal/src/Journal/Internal/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ metricsAvg metrics label = do
c <- count metrics label
return (realToFrac s / realToFrac c)

msyncMetrics :: Metrics c h -> IO ()
msyncMetrics (Metrics cbuf hbuf) = do
force cbuf
force hbuf

------------------------------------------------------------------------

-- * Example

data MyMetricsCounter = Connections
Expand Down
3 changes: 3 additions & 0 deletions src/journal/src/Journal/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ readFrameLength :: ByteBuffer -> TermOffset -> IO HeaderLength
readFrameLength termBuffer termOffset = HeaderLength <$>
readInt32OffAddr termBuffer (fromIntegral termOffset + fRAME_LENGTH_FIELD_OFFSET)

msyncMetadata :: Metadata -> IO ()
msyncMetadata (Metadata meta) = force meta

------------------------------------------------------------------------

newtype HeaderTag = HeaderTag { unHeaderTag :: Word8 }
Expand Down
8 changes: 7 additions & 1 deletion src/sut/dumblog/src/Dumblog/Metrics/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ metricsMain = do
metrics <- newMetrics dumblogSchema dUMBLOG_METRICS
eMeta <- journalMetadata dUMBLOG_JOURNAL dumblogOptions

msyncMetrics metrics
either (const (return ())) msyncMetadata eMeta

putStrLn ansiClearScreen
displayServiceTime metrics
displayQueueDepth metrics
Expand Down Expand Up @@ -85,8 +88,11 @@ displayServiceTime metrics = do
printf " 99.9 %10.2f µs%15.2fµs\n" (fromMaybe 0 m999) (fromMaybe 0 m999')
printf " 99.99 %10.2f µs%15.2fµs\n" (fromMaybe 0 m9999) (fromMaybe 0 m9999')
printf " max %10.2f µs%15.2fµs\n" (fromMaybe 0 mMax) (fromMaybe 0 mMax')
writeSum <- realToFrac <$> metricsSum metrics ServiceTimeWrites :: IO Double
readSum <- realToFrac <$> metricsSum metrics ServiceTimeReads :: IO Double
writeCnt <- count metrics ServiceTimeWrites
readCnt <- count metrics ServiceTimeReads
printf " sum %10.2f s%15.2fs\n" (writeSum / 1e6) (readSum / 1e6)
let totalCnt :: Double
totalCnt = realToFrac (writeCnt + readCnt)
printf " count %7d (%2.0f%%) %10d (%2.0f%%)\n"
Expand Down Expand Up @@ -159,4 +165,4 @@ displayErrors metrics = do
displayUtilisation :: DumblogMetrics -> ThroughputState -> IO ()
displayUtilisation metrics ts = do
serviceTimeAvg <- metricsAvg metrics ServiceTimeWrites -- XXX: what about reads?
printf "\nUtilisation: %.2f\n" (throughputAvg ts * serviceTimeAvg)
printf "\nUtilisation: %.2f\n" (throughputAvg ts * serviceTimeAvg * 1e-6)

0 comments on commit 4221557

Please sign in to comment.