Skip to content

Commit d040195

Browse files
karknucoot
authored andcommitted
Add duration to TxInboundAddedToMempool
Add the time it took to add TXs to the mempool to the TxInboundAddedToMempool tracer.
1 parent aa064d9 commit d040195

File tree

3 files changed

+12
-3
lines changed
  • ouroboros-network

3 files changed

+12
-3
lines changed

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ unit_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
934934
case x of
935935
-- When we add txids to the mempool, we collect them
936936
-- into the map
937-
DiffusionTxSubmissionInbound (TraceTxInboundAddedToMempool txids) ->
937+
DiffusionTxSubmissionInbound (TraceTxInboundAddedToMempool txids _) ->
938938
Map.alter (maybe (Just []) (Just . sort . (txids ++))) n rr
939939
-- When the node is shutdown we have to reset the accepted
940940
-- txids list

ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/Server.hs

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Data.Set qualified as Set
1616
import Control.Concurrent.Class.MonadSTM.Strict
1717
import Control.Exception (assert)
1818
import Control.Monad.Class.MonadThrow
19+
import Control.Monad.Class.MonadTime.SI
1920
import Control.Tracer (Tracer, traceWith)
2021

2122
import Network.TypedProtocol
@@ -43,6 +44,7 @@ txSubmissionInboundV2
4344
:: forall txid tx idx m.
4445
( MonadSTM m
4546
, MonadThrow m
47+
, MonadMonotonicTime m
4648
, Ord txid
4749
)
4850
=> Tracer m (TraceTxSubmissionInbound txid tx)
@@ -70,9 +72,15 @@ txSubmissionInboundV2
7072
txd@TxDecision { txdTxsToRequest = txsToReq, txdTxsToMempool = txs }
7173
<- readTxDecision
7274
traceWith tracer (TraceTxInboundDecision txd)
75+
76+
!start <- getMonotonicTime
7377
txidsAccepted <- mempoolAddTxs txs
78+
!end <- getMonotonicTime
79+
let duration = diffTime end start
80+
7481
traceWith tracer $
75-
TraceTxInboundAddedToMempool txidsAccepted
82+
TraceTxInboundAddedToMempool txidsAccepted duration
83+
7684
let !collected = length txs
7785
let !accepted = length txidsAccepted
7886
traceWith tracer $

ouroboros-network/src/Ouroboros/Network/TxSubmission/Inbound/Types.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module Ouroboros.Network.TxSubmission.Inbound.Types
2424
) where
2525

2626
import Control.Exception (Exception (..))
27+
import Control.Monad.Class.MonadTime.SI
2728
import Data.Map.Strict (Map)
2829
import Data.Sequence.Strict (StrictSeq)
2930
import Data.Set (Set)
@@ -297,7 +298,7 @@ data TraceTxSubmissionInbound txid tx =
297298
-- | Server received 'MsgDone'
298299
| TraceTxInboundCanRequestMoreTxs Int
299300
| TraceTxInboundCannotRequestMoreTxs Int
300-
| TraceTxInboundAddedToMempool [txid]
301+
| TraceTxInboundAddedToMempool [txid] DiffTime
301302

302303
--
303304
-- messages emitted by the new implementation of the server in

0 commit comments

Comments
 (0)