-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EKG counter for tips served #3300
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -498,9 +498,6 @@ isRollForward :: TraceChainSyncServerEvent blk -> Bool | |
isRollForward (TraceChainSyncRollForward _) = True | ||
isRollForward _ = False | ||
|
||
isTraceBlockFetchServerBlockCount :: TraceBlockFetchServerEvent blk -> Bool | ||
isTraceBlockFetchServerBlockCount (TraceBlockFetchServerSendBlock _) = True | ||
|
||
mkConsensusTracers | ||
:: forall blk peer localPeer. | ||
( Show peer | ||
|
@@ -533,7 +530,9 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do | |
forgeTracers <- mkForgeTracers | ||
meta <- mkLOMeta Critical Public | ||
|
||
tBlocksServed <- STM.newTVarIO @Int 0 | ||
tBlocksServed <- STM.newTVarIO 0 | ||
tLocalUp <- STM.newTVarIO 0 | ||
tMaxSlotNo <- STM.newTVarIO $ SlotNo 0 | ||
tSubmissionsCollected <- STM.newTVarIO 0 | ||
tSubmissionsAccepted <- STM.newTVarIO 0 | ||
tSubmissionsRejected <- STM.newTVarIO 0 | ||
|
@@ -555,12 +554,8 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do | |
, Consensus.blockFetchClientTracer = traceBlockFetchClientMetrics mbEKGDirect tBlockDelayM | ||
tBlockDelayCDF1s tBlockDelayCDF3s tBlockDelayCDF5s $ | ||
tracerOnOff (traceBlockFetchClient trSel) verb "BlockFetchClient" tr | ||
, Consensus.blockFetchServerTracer = tracerOnOff' (traceBlockFetchServer trSel) $ | ||
Tracer $ \ev -> do | ||
traceWith (annotateSeverity . toLogObject' verb $ appendName "BlockFetchServer" tr) ev | ||
when (isTraceBlockFetchServerBlockCount ev) $ | ||
traceI trmet meta "served.block.count" =<< | ||
STM.modifyReadTVarIO tBlocksServed (+1) | ||
, Consensus.blockFetchServerTracer = traceBlockFetchServerMetrics trmet meta tBlocksServed | ||
tLocalUp tMaxSlotNo $ tracerOnOff (traceBlockFetchServer trSel) verb "BlockFetchServer" tr | ||
, Consensus.forgeStateInfoTracer = tracerOnOff' (traceForgeStateInfo trSel) $ | ||
forgeStateInfoTracer (Proxy @ blk) trSel tr | ||
, Consensus.txInboundTracer = tracerOnOff' (traceTxInbound trSel) $ | ||
|
@@ -621,6 +616,46 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do | |
when (isRollForward ev) $ | ||
sendEKGDirectCounter ekgDirect "cardano.node.metrics.served.header.counter.int" | ||
|
||
traceBlockFetchServerMetrics | ||
:: forall blk. () | ||
=> Tracer IO (LoggerName, LogObject Text) | ||
-> LOMeta | ||
-> STM.TVar Int64 | ||
-> STM.TVar Int64 | ||
-> STM.TVar SlotNo | ||
-> Tracer IO (TraceBlockFetchServerEvent blk) | ||
-> Tracer IO (TraceBlockFetchServerEvent blk) | ||
traceBlockFetchServerMetrics trMeta meta tBlocksServed tLocalUp tMaxSlotNo tracer = Tracer bsTracer | ||
|
||
where | ||
bsTracer :: TraceBlockFetchServerEvent blk -> IO () | ||
bsTracer e@(TraceBlockFetchServerSendBlock p) = do | ||
traceWith tracer e | ||
|
||
(served, mbLocalUpstreamyness) <- atomically $ do | ||
served <- STM.modifyReadTVar' tBlocksServed (+1) | ||
maxSlotNo <- STM.readTVar tMaxSlotNo | ||
case pointSlot p of | ||
Origin -> return (served, Nothing) | ||
At slotNo -> | ||
case compare maxSlotNo slotNo of | ||
LT -> do | ||
STM.writeTVar tMaxSlotNo slotNo | ||
lu <- STM.modifyReadTVar' tLocalUp (+1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is Is it equialvent to:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return (served, Just lu) | ||
GT -> do | ||
return (served, Nothing) | ||
EQ -> do | ||
lu <- STM.modifyReadTVar' tLocalUp (+1) | ||
return (served, Just lu) | ||
|
||
traceI trMeta meta "served.block.count" served | ||
case mbLocalUpstreamyness of | ||
Just localUpstreamyness -> | ||
traceI trMeta meta "served.block.latest.count" localUpstreamyness | ||
Nothing -> return () | ||
|
||
|
||
-- | CdfCounter tracks the number of time a value below 'limit' has been seen. | ||
newtype CdfCounter (limit :: Nat) = CdfCounter Int64 | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the local upstreaminess metric which tries to answer the question: how many times we serve a block which slot is either equal or ahead of last served block.
I would like to see a description how this related to the upstreaminess metric that is used to choose peers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should mention that at all. This is a useful metric on its own, regardless of if that is how down stream peers may judge the node in the future.