Skip to content

Commit a9cd34d

Browse files
committed
Add duration to TxInboundAddedToMempool
Add the time it took to add TXs to the mempool to the TxInboundAddedToMempool tracer.
1 parent 168d247 commit a9cd34d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ unit_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
588588
case x of
589589
-- When we add txids to the mempool, we collect them
590590
-- into the map
591-
DiffusionTxSubmissionInbound (TraceTxInboundAddedToMempool txids) ->
591+
DiffusionTxSubmissionInbound (TraceTxInboundAddedToMempool txids _) ->
592592
Map.alter (maybe (Just []) (Just . sort . (txids ++))) n rr
593593
-- When the node is shutdown we have to reset the accepted
594594
-- txids list

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

Lines changed: 9 additions & 1 deletion
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.Pipelined
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module Ouroboros.Network.TxSubmission.Inbound.Types
2222
) where
2323

2424
import Control.Exception (Exception (..))
25+
import Control.Monad.Class.MonadTime.SI
2526
import Data.Map.Strict (Map)
2627
import Data.Sequence.Strict (StrictSeq)
2728
import Data.Set (Set)
@@ -294,7 +295,7 @@ data TraceTxSubmissionInbound txid tx =
294295
-- | Server received 'MsgDone'
295296
| TraceTxInboundCanRequestMoreTxs Int
296297
| TraceTxInboundCannotRequestMoreTxs Int
297-
| TraceTxInboundAddedToMempool [txid]
298+
| TraceTxInboundAddedToMempool [txid] DiffTime
298299

299300
--
300301
-- messages emitted by the new implementation of the server in

0 commit comments

Comments
 (0)