Skip to content

Commit

Permalink
refactor(sut): shuffle worker loop around a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Mar 18, 2022
1 parent 5816d85 commit 16f03d3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions doc/demo-journal/slides-journal.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ done
# Disable turbo boost.
echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo

# Allow for more open file descriptors.
ulimit -n unlimited

# The following run is just a (CPU) warm up, the results are discarded.
cabal run bench-sqlite

Expand Down
Binary file modified doc/demo-journal/slides-journal.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/sut/dumblog/bench/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rEAD_FREQUENCY :: Int
rEAD_FREQUENCY = 80

iTERATIONS :: Int
iTERATIONS = 50000
iTERATIONS = 100000

vALUE_TO_WRITE :: ByteString
vALUE_TO_WRITE = LBS.pack "Dumblog"
Expand Down
31 changes: 14 additions & 17 deletions src/sut/dumblog/src/Dumblog/Journal/Worker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ worker :: Journal -> DumblogMetrics -> WorkerInfo -> InMemoryDumblog -> IO ()
worker journal metrics (WorkerInfo blocker logger snapshotFile currentVersion eventCount untilSnapshot) =
go eventCount
where
go ev s
| ev >= untilSnapshot = do
logger "[worker] Performing Snapshot"
bytes <- readBytesConsumed (jMetadata journal) Sub1
Snapshot.toFile (Snapshot.Snapshot bytes currentVersion s) snapshotFile
writeBytesConsumed (jMetadata journal) Sub2 bytes
go 0 s
go :: Int -> InMemoryDumblog -> IO ()
go ev s = do
{ val <- Journal.readJournal journal Sub1
; (ev', s') <- case val of
{ Nothing -> return (ev, s)
; Just entry -> do
if ev >= untilSnapshot
then do
logger "[worker] Performing Snapshot"
bytes <- readBytesConsumed (jMetadata journal) Sub1
Snapshot.toFile (Snapshot.Snapshot bytes currentVersion s) snapshotFile
writeBytesConsumed (jMetadata journal) Sub2 bytes
go 0 s
else do
mEntry <- Journal.readJournal journal Sub1
case mEntry of
Nothing -> threadDelay 0 >> go ev s
Just entry -> do
Metrics.decrCounter_ metrics QueueDepth 1
let Envelope key cmd version arrivalTime = decode entry
-- XXX: In case of decode error:
Expand All @@ -81,9 +83,4 @@ worker journal metrics (WorkerInfo blocker logger snapshotFile currentVersion ev
case cmd of
Write bs -> Metrics.measure metrics WriteSize (realToFrac (BS.length bs))
_otherwise -> return ()
return (succ ev, s')

}
; threadDelay 10
; go ev' s'
}
go (ev + 1) s'
3 changes: 3 additions & 0 deletions src/sut/dumblog/tools/benchmark-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ cabal build "${BENCHMARK_CABAL_BUILD_OPTS[@]}" "${BENCHMARK_WORKLOAD2}"
# Disable turbo boost.
echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo

# Allow for more open file descriptors.
ulimit -n unlimited

# The following run is just a (CPU) warm up, the results are discarded.
cabal run "${BENCHMARK_CABAL_RUN_OPTS[@]}" "${BENCHMARK_WORKLOAD2}"

Expand Down

0 comments on commit 16f03d3

Please sign in to comment.