Skip to content
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

[core] Reworked the CRcvBuffer::dropMessage(..) function. #2661

Merged
merged 4 commits into from
Feb 14, 2023

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Feb 13, 2023

To improve the CRcvBuffer::dropMessage(..) performance the packets are dropped based on pkt seqno range first.
Then, if the start of the message has not been dropped, and additional search step from the seqnolo position downwards is applied to look for a packet with PB_FIRST boundary flag.

Proceeding after #2657.

@gou4shi1 please have a look.

Drop by seqno offset first, then refine using msgno.
@maxsharabayko maxsharabayko added Type: Maintenance Work required to maintain or clean up the code [core] Area: Changes in SRT library core labels Feb 13, 2023
@maxsharabayko maxsharabayko added this to the v1.5.2 milestone Feb 13, 2023
@gou4shi1
Copy link
Contributor

gou4shi1 commented Feb 13, 2023

What if seqnohi is not the last packet of the message to drop?
For example, seqno of msg2 is 3-5 but this function is called with (msgno=2, seqlo=3, seqhi=4).
I took a rough look, this case should not happen in the current codebase, but we shuould add some sane checks (for future) or at least document this constraint?

@maxsharabayko
Copy link
Collaborator Author

What if seqnohi is not the last packet of the message to drop? For example, seqno of msg2 is 3-5 but this function is called with (msgno=2, seqlo=3, seqhi=4). I took a rough look, this case should not happen in the current codebase, but we shuould add some sane checks (for future) or at least document this constraint?

This can only happen in case the sender reports an invalid range. In general, the sender should have at least the last packet of the message it is requesting to be dropped.

@gou4shi1
Copy link
Contributor

gou4shi1 commented Feb 13, 2023

In general, the sender should have at least the last packet of the message it is requesting to be dropped.

Agreed, but would be nice to have it documented or commented.

@maxsharabayko maxsharabayko marked this pull request as ready for review February 14, 2023 11:58
@maxsharabayko maxsharabayko merged commit 599c1fb into Haivision:master Feb 14, 2023
@maxsharabayko maxsharabayko deleted the hotfix/rcv-dropmsg branch February 14, 2023 14:22
const int stop_pos = decPos(m_iStartPos);
for (int i = start_pos; i != stop_pos; i = decPos(i))
{
// Can't drop is message number is not known.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is -> if?

if (minDroppedOffset == -1)
minDroppedOffset = offPos(m_iStartPos, i);
else
minDroppedOffset = min(offPos(m_iStartPos, i), minDroppedOffset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it''s searching backward, min() is useless?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm.. Why? We need to find the minimum offset.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new offset should always be the smaller one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, minDroppedOffset is later used to check if the next reading position should be updated.

const bool needUpdateNonreadPos = (minDroppedOffset != -1 && minDroppedOffset <= getRcvDataSize());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the new offPos(m_iStartPos, i) should always smaller than minDroppedOffset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, right. Given the search stays always backward it should be enough to just set minDroppedOffset = offPos(m_iStartPos, i).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants