Skip to content

Commit

Permalink
Merge pull request #3376 from marta-lokhova/logging_improvements
Browse files Browse the repository at this point in the history
Improve overlay logging

Reviewed-by: MonsieurNicolas
  • Loading branch information
latobarita authored Mar 16, 2022
2 parents 6a1be16 + 20ef0c2 commit 99d82e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/overlay/Peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ Peer::beginMesssageProcessing(StellarMessage const& msg)
mCapacity.mFloodCapacity--;
if (mCapacity.mFloodCapacity == 0)
{
CLOG_TRACE(Overlay, "{}: no capacity for peer {}",
mApp.getConfig().toShortString(
mApp.getConfig().NODE_SEED.getPublicKey()),
CLOG_DEBUG(Overlay, "No flood capacity for peer {}",
mApp.getConfig().toShortString(getPeerID()));
}
}
Expand Down Expand Up @@ -779,6 +777,12 @@ Peer::recvMessage(StellarMessage const& stellarMsg)
return;
}
mNoOutboundCapacity.reset();
if (mOutboundCapacity == 0 &&
stellarMsg.sendMoreMessage().numMessages != 0)
{
CLOG_DEBUG(Overlay, "Got outbound capacity for peer {}",
mApp.getConfig().toShortString(getPeerID()));
}
mOutboundCapacity += stellarMsg.sendMoreMessage().numMessages;
break;
}
Expand Down Expand Up @@ -1007,6 +1011,8 @@ Peer::maybeSendNextBatch()
mOutboundCapacity--;
if (mOutboundCapacity == 0)
{
CLOG_DEBUG(Overlay, "No outbound capacity for peer {}",
mApp.getConfig().toShortString(getPeerID()));
mNoOutboundCapacity =
std::make_optional<VirtualClock::time_point>(
mApp.getClock().now());
Expand All @@ -1032,12 +1038,12 @@ Peer::endMessageProcessing(StellarMessage const& msg)
mCapacity.mTotalCapacity++;
if (mApp.getOverlayManager().isFloodMessage(msg))
{
if (mCapacity.mFloodCapacity == 0)
{
CLOG_DEBUG(Overlay, "Got flood capacity for peer {}",
mApp.getConfig().toShortString(getPeerID()));
}
mCapacity.mFloodCapacity++;
CLOG_TRACE(Overlay, "{}: got capacity {} for peer {}",
mApp.getConfig().toShortString(
mApp.getConfig().NODE_SEED.getPublicKey()),
mCapacity.mFloodCapacity,
mApp.getConfig().toShortString(getPeerID()));
mFloodMsgsProcessed++;

if (mFloodMsgsProcessed ==
Expand All @@ -1051,6 +1057,8 @@ Peer::endMessageProcessing(StellarMessage const& msg)
// Got some capacity back, can schedule more reads now
if (mIsPeerThrottled)
{
CLOG_DEBUG(Overlay, "Stop throttling reading from peer {}",
mApp.getConfig().toShortString(getPeerID()));
mIsPeerThrottled = false;
scheduleRead();
}
Expand Down
4 changes: 2 additions & 2 deletions src/overlay/TCPPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ TCPPeer::startRead()
if (!hasReadingCapacity())
{
// Break and wait until more capacity frees up
CLOG_TRACE(Overlay, "Throttle reading for peer {}!",
CLOG_DEBUG(Overlay, "Throttle reading from peer {}!",
mApp.getConfig().toShortString(getPeerID()));
mIsPeerThrottled = true;
return;
Expand Down Expand Up @@ -645,7 +645,7 @@ TCPPeer::readBodyHandler(asio::error_code const& error,
if (!hasReadingCapacity())
{
// No more capacity after processing this message
CLOG_TRACE(Overlay,
CLOG_DEBUG(Overlay,
"TCPPeer::readBodyHandler: throttle reading from {}",
mApp.getConfig().toShortString(getPeerID()));
mIsPeerThrottled = true;
Expand Down

0 comments on commit 99d82e5

Please sign in to comment.