Skip to content

Commit 70e2127

Browse files
[core] Slowdown 'ACKACK out of order' log frequency (#3007).
1 parent 49cab20 commit 70e2127

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

srtcore/core.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5965,7 +5965,7 @@ bool srt::CUDT::frequentLogAllowed(size_t logid, const time_point& tnow, std::st
59655965
#endif
59665966

59675967
bool is_suppressed = IsSet(m_LogSlowDownExpired, BIT(logid));
5968-
bool isnow = (m_tsLogSlowDown.load() + milliseconds_from(SRT_LOG_SLOWDOWN_FREQ_MS)) <= tnow;
5968+
const bool isnow = (m_tsLogSlowDown[logid].load() + milliseconds_from(SRT_LOG_SLOWDOWN_FREQ_MS)) <= tnow;
59695969
if (isnow)
59705970
{
59715971
// Theoretically this should prevent other calls of this function to take
@@ -5977,19 +5977,19 @@ bool srt::CUDT::frequentLogAllowed(size_t logid, const time_point& tnow, std::st
59775977
// Note: it may happen that two threads could intermix one another between
59785978
// the check and setting up, but this will at worst case set the slightly
59795979
// later time again.
5980-
m_tsLogSlowDown.store(tnow);
5980+
m_tsLogSlowDown[logid].store(tnow);
59815981

59825982
is_suppressed = false;
59835983

5984-
int supr = m_aSuppressedMsg[logid];
5984+
const int supr = m_aSuppressedMsg[logid];
59855985

59865986
if (supr > 0)
59875987
w_why = Sprint("++SUPPRESSED: ", supr);
59885988
m_aSuppressedMsg[logid] = 0;
59895989
}
59905990
else
59915991
{
5992-
w_why = Sprint("Too early - last one was ", FormatDuration<DUNIT_MS>(tnow - m_tsLogSlowDown.load()));
5992+
w_why = Sprint("Too early - last one was ", FormatDuration<DUNIT_MS>(tnow - m_tsLogSlowDown[logid].load()));
59935993
// Set YOUR OWN bit, atomically.
59945994
m_LogSlowDownExpired |= uint8_t(BIT(logid));
59955995
++m_aSuppressedMsg[logid];
@@ -8688,10 +8688,21 @@ void srt::CUDT::processCtrlAckAck(const CPacket& ctrlpkt, const time_point& tsAr
86888688
{
86898689
if (ctrlpkt.getAckSeqNo() > (m_iAckSeqNo - static_cast<int>(ACK_WND_SIZE)) && ctrlpkt.getAckSeqNo() <= m_iAckSeqNo)
86908690
{
8691-
LOGC(inlog.Note,
8692-
log << CONID() << "ACKACK out of order, skipping RTT calculation "
8693-
<< "(ACK number: " << ctrlpkt.getAckSeqNo() << ", last ACK sent: " << m_iAckSeqNo
8694-
<< ", RTT (EWMA): " << m_iSRTT << ")");
8691+
string why;
8692+
if (frequentLogAllowed(FREQLOGFA_ACKACK_OUTOFORDER, tsArrival, (why)))
8693+
{
8694+
LOGC(inlog.Note,
8695+
log << CONID() << "ACKACK out of order, skipping RTT calculation "
8696+
<< "(ACK number: " << ctrlpkt.getAckSeqNo() << ", last ACK sent: " << m_iAckSeqNo
8697+
<< ", RTT (EWMA): " << m_iSRTT << ")." << why);
8698+
}
8699+
#if SRT_ENABLE_FREQUENT_LOG_TRACE
8700+
else
8701+
{
8702+
LOGC(qrlog.Note, log << "SUPPRESSED: ACKACK out of order LOG: " << why);
8703+
}
8704+
#endif
8705+
86958706
return;
86968707
}
86978708

srtcore/core.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,15 @@ class CUDT
948948
int32_t m_iReXmitCount; // Re-Transmit Count since last ACK
949949

950950
static const size_t
951-
MAX_FREQLOGFA = 2,
952951
FREQLOGFA_ENCRYPTION_FAILURE = 0,
953-
FREQLOGFA_RCV_DROPPED = 1;
954-
atomic_time_point m_tsLogSlowDown; // The last time a log message from the "slow down" group was shown.
955-
// The "slow down" group of logs are those that can be printed too often otherwise, but can't be turned off (warnings and errors).
956-
// Currently only used by decryption failure message, therefore no mutex protection needed.
957-
sync::atomic<uint8_t> m_LogSlowDownExpired; // Can't use bitset because atomic
952+
FREQLOGFA_RCV_DROPPED = 1,
953+
FREQLOGFA_ACKACK_OUTOFORDER = 2,
954+
MAX_FREQLOGFA = 3;
955+
956+
atomic_time_point m_tsLogSlowDown[MAX_FREQLOGFA]; // The last time a log message from the "slow down" group was shown.
957+
// The "slow down" group of logs are those that can be printed too often otherwise, but can't be turned off (warnings and errors).
958+
// Currently only used by decryption failure message, therefore no mutex protection needed.
959+
sync::atomic<uint8_t> m_LogSlowDownExpired; // Can't use bitset because atomic
958960
sync::atomic<int> m_aSuppressedMsg[MAX_FREQLOGFA];
959961

960962
/// @brief Check if a frequent log can be shown.

0 commit comments

Comments
 (0)