-
Notifications
You must be signed in to change notification settings - Fork 851
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
Refax: removed m_iRcvLastSkipAck and its dependencies #2546
Refax: removed m_iRcvLastSkipAck and its dependencies #2546
Conversation
…eUpTo convention for including given seqno. Removed unused updateForgotten.
This comment was marked as off-topic.
This comment was marked as off-topic.
srtcore/buffer_rcv.cpp
Outdated
@@ -1050,13 +1050,13 @@ void CRcvBuffer::updateTsbPdTimeBase(uint32_t usPktTimestamp) | |||
|
|||
string CRcvBuffer::strFullnessState(bool enable_debug_log, int iFirstUnackSeqNo, const time_point& tsNow) const | |||
{ | |||
if (!enable_debug_log) |
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.
The reason of this enable_debug_log
check: #2463 (comment)
If return empty string, why not just check enable_debug_log
in the caller site? i.e. qrlog.Debug.CheckEnabled() ? strFullnessState() : ""
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.
Because the idea is to avoid the lengthy evaluation when the resulting string will be ignored anyway. The instruction for logging will not result in a printed log if the log isn't enabled, but all the arguments will be evaluated anyway.
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.
the lengthy evaluation
Does it mean qrlog.Debug.CheckEnabled() ? strFullnessState() : ""
?
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.
Probably would work as well. @maxsharabayko what do you think?
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.
Does it mean
qrlog.Debug.CheckEnabled() ? strFullnessState() : ""
?
Good suggestion. And get rid of the enable_debug_log
argument.
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.
Maybe even this way? At least this improves reliability over the explicit version:
<< LOGEVAL_IF(qrlog.Warn, m_pRcvBuffer->strFullnessState(m_iRcvLastAck, steady_clock::now()))
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.
Some minor comments about logs.
<< " m_iStartPos=" << m_iStartPos << " m_iMaxPosInc=" << m_iMaxPosInc << ". "; | ||
} | ||
ss << "iFirstUnackSeqNo=" << iFirstUnackSeqNo << " m_iStartSeqNo=" << m_iStartSeqNo | ||
<< " m_iStartPos=" << m_iStartPos << " m_iMaxPosInc=" << m_iMaxPosInc << ". "; | ||
|
||
ss << "Space avail " << getAvailSize(iFirstUnackSeqNo) << "/" << m_szSize << " pkts. "; |
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.
Now that the no room check has nothing to do with getAvailSize(ack)
, this "Space avail..." log should also be changed or removed, e.g. https://github.com/Haivision/srt/pull/2535/files#diff-45454334aff81b7e3327c5453befe97eb41e7ec0c3bdfc695e25949ba9f463adL1061
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 actually don't understand what is happening here. I raised some concerns already about the way how the "avail space" is calculated. I didn't trace that before, but that all depends on what you're going to use this value for. The sequence of acknowledgement is only a marker of the part of the buffer not yet retrieved by the application. But rest of the buffer contains two ranges: working range (packets that are there, maybe with losses, but haven't been yet acknowledged) and available range (no packet with such a sequence has come even for the first time). A sender that is about to decide as to whether it can send the packet and count on that the receiver has a place to store it, should be given only this last "available" range. But also the sender should regard this free space value only when going to send the new packets, not when retransmitting. Retransmission should use the "working range" which should always be available. But now I'm not exactly sure how to best display it.
srtcore/core.cpp
Outdated
// Remove [from,to-inclusive] | ||
dropFromLossLists(m_iRcvLastSkipAck, CSeqNo::decseq(seqno)); | ||
m_iRcvLastSkipAck = seqno; | ||
LOGC(tslog.Error, log << CONID() << "IPE: drop request up to %" << seqno << " while last received is %" |
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.
It's not an IPE in group mode, it will happen frequently if it's called from dropToGroupRecvBase()
in broadcast mode, IIRC.
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.
Right. Forgot that this function is also being used from the group synchronization code, and in this case this sequence may exceed the last received sequence. Still, AFAIR this last received sequence has to be synchronized as well. Fortunately this will remain only temporarily, until the common receiver buffer is ready.
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 last received sequence has to be synchronized as well
I tried, this may break senders' check:
if (CSeqNo::seqcmp(ackdata_seqno, CSeqNo::incseq(m_iSndCurrSeqNo)) > 0)
{
leaveCS(m_RecvAckLock);
// this should not happen: attack or bug
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.
That's why I'd simply leave it as is for now. The common receiver code will approach this part differently.
@@ -9749,14 +9763,12 @@ int srt::CUDT::handleSocketPacketReception(const vector<CUnit*>& incoming, bool& | |||
m_stats.rcvr.recvdBelated.count(rpkt.getLength()); | |||
leaveCS(m_StatsLock); | |||
HLOGC(qrlog.Debug, | |||
log << CONID() << "RECEIVED: seq=" << rpkt.m_iSeqNo << " offset=" << offset << " (BELATED/" | |||
log << CONID() << "RECEIVED: %" << rpkt.m_iSeqNo << " bufidx=" << bufidx << " (BELATED/" |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
<< "+" << CSeqNo::incseq(m_iRcvLastSkipAck, int(m_pRcvBuffer->capacity()) - 1) | ||
<< "), " << (offset-avail_bufsize+1) | ||
" %" << rpkt.m_iSeqNo | ||
<< " buffer=(%" << bufseq |
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.
<< "buffer=(%" << bufseq
<< ":%" << m_iRcvCurrSeqNo
<< "+%" << CSeqNo::incseq(bufseq, int(m_pRcvBuffer->capacity()) - 1)
<< ")"
This code block was repeated many times, maybe add a dedicated function?
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.
Might be, but I'd postpone it until the common receiver as things may change there a lot. In case of a common receiver there will be a different buffer where data come from.
// [[using locked(m_RcvBufferLock)]] | ||
bool srt::CUDT::getFirstNoncontSequence(int32_t& w_seq, string& w_log_reason) |
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.
Given the function return value is always true
and thus can be ignored, might make sense to return the w_seq
instead of passing it as a reference.
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 is consistent with the future implementation of it where it returns false in case when it neither has a receiver buffer nor is a group member. This situation should never happen and therefore for this it's a sanity check. I can change it, but this will cause merge problems in the future.
srtcore/core.cpp
Outdated
<< ":" << m_iRcvCurrSeqNo // -1 = size to last index | ||
<< "+" << CSeqNo::incseq(m_iRcvLastSkipAck, m_pRcvBuffer->capacity()-1) | ||
// XXX Fix this when the end of contiguous region detection is added. | ||
int ackidx = CSeqNo::seqoff(m_pRcvBuffer->getStartSeqNo(), m_iRcvLastAck); |
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.
int ackidx = CSeqNo::seqoff(m_pRcvBuffer->getStartSeqNo(), m_iRcvLastAck); | |
const int ackidx = CSeqNo::seqoff(m_pRcvBuffer->getStartSeqNo(), m_iRcvLastAck); |
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.
The instruction two lines below this will not compile.
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.
Can be converted into a single line using the std::max(0, CSeqNo...)
.
Removed the
m_iRcvLastSkipAck
field. This field was different tom_iRcvLastAck
in case when a drop was done and was used as a base sequence pinned in the old receiver buffer to the "end pointer" that was pointing to the end of the initial contiguous region. With the defined sequence number of the first cell in the new receiver buffer this field was only duplicating the information as well as the convention where the acknowledgement signs off packets for retrieval in live mode as well has been dismissed (this is still valid in file mode, but relies on only signaling the CV and setting read ready; both these things are being done by the TSBPD thread in live mode). The value of this field can be determined fromm_iRcvLastAck
andm_pRcvBuffer->getStartSeqNo()
, whichever is later, however the way how this value was used in comparisons had to be changed as well, as the check if a sequence is within the buffer can be now done more straighforward way.