Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Add comment about MVar choice
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini committed Jun 10, 2022
1 parent 794c6a7 commit 84a2d62
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plutus-streaming/src/Plutus/Streaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ withChainSyncEventStream socketPath networkId point consumer = do
-- receives to the stream consumer through a MVar. The chain-sync client
-- thread and the stream consumer will each block on each other and stay
-- in lockstep.
--
-- NOTE: choosing a MVar is a tradeoff towards simplicity. In this case a
-- (bounded) queue could perform better. Indeed a properly-sized buffer
-- can reduce the time the two threads are blocked waiting for each
-- other. The problem here is "properly-sized". A bounded queue like
-- Control.Concurrent.STM.TBQueue allows us to specify a max queue length
-- but block size can vary a lot (TODO quantify this) depending on the
-- era. We have an alternative implementation with customizable
-- (TBMQueue) but it needs to be extracted from the
-- plutus-chain-index-core package. Using a simple MVar doesn't seem to
-- slow down marconi's indexing, likely because the difference is
-- negligeable compared to existing network and IO latencies.
-- Therefore, let's stick with a MVar now and revisit later.
nextBlockVar <- newEmptyMVar

let client = chainSyncStreamingClient point nextBlockVar
Expand Down

0 comments on commit 84a2d62

Please sign in to comment.