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

rx register rewrite #348

Merged
merged 4 commits into from
Sep 15, 2023
Merged

rx register rewrite #348

merged 4 commits into from
Sep 15, 2023

Conversation

davibe
Copy link
Collaborator

@davibe davibe commented Sep 13, 2023

  • separate nack and RR generation
  • remove misorder delay
  • remove probation period
  • simplify handing nack to avoiding unnecessary operations

@davibe davibe force-pushed the feature/new-rx-register branch 4 times, most recently from 9ebbee8 to 1b61c7e Compare September 13, 2023 16:15
@davibe davibe marked this pull request as ready for review September 13, 2023 16:20
Copy link
Owner

@algesten algesten left a comment

Choose a reason for hiding this comment

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

Overall looks good.

  • I don't like the name ReceptionRegister, because it's just some jitter calculation.
  • Let's not make a separate module. Rename register/mod.rs back to register.rs and merge ReceptionRegister (and rename it) into register.rs
  • You can have the nack in a separate. Call it something like register_nack.rs to tie them together by name.

@davibe davibe force-pushed the feature/new-rx-register branch from 1b61c7e to 5b1d8fe Compare September 14, 2023 07:02
Copy link
Collaborator

@k0nserv k0nserv left a comment

Choose a reason for hiding this comment

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

Some assorted thoughts, mostly just nitpicks and potential performance improvements

src/streams/register/mod.rs Outdated Show resolved Hide resolved
src/streams/register_nack.rs Show resolved Hide resolved
src/streams/register_nack.rs Show resolved Hide resolved
src/streams/register_nack.rs Outdated Show resolved Hide resolved
return None;
}

let mut nacks = vec![];
Copy link
Collaborator

@k0nserv k0nserv Sep 14, 2023

Choose a reason for hiding this comment

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

ReportList is designed to have a fixed size so it seems wasteful to allocate here. Instead we can use ReportList::new and then ReportList::push.

Also the result of this method gets pushed onto a &mut VecDeque<Rtcp> that is allocated a single time in Session. We could entirely avoid allocating here if we changed the signature to

pub fn nack_report(&mut self, on_nack: F)
where 
  F: FnMut(nack: Nack)

Copy link
Owner

Choose a reason for hiding this comment

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

Since this is tightly coupled to the RTCP type, I don't mind making it produce the specific type directly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So

pub fn nack_report(&mut self, on_nack: F)
where 
  F: FnMut(rtcp: Rtcp)

?

Copy link
Owner

Choose a reason for hiding this comment

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

Either the way we collect feedback through the rest of handle_timeout

pub fn nack_report(&mut self, feedback: &mut VecDeque<Rtcp>) {}

or

pub fn nack_report(&mut self) -> Option<Rtcp> {}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Aight, I guess the former is slightly more flexible since nack_report could, in theory, produce two instances of Rtcp. But I guess we might not want to cause that much NACKing anyway

src/streams/register_nack.rs Show resolved Hide resolved
assert_update(&mut reg, 10, true, true, 10..10);

// packet before window start is ignored
assert_update(&mut reg, 9, false, false, 10..10);
Copy link
Collaborator

@k0nserv k0nserv Sep 14, 2023

Choose a reason for hiding this comment

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

Does this means we could lose out on some packets if we get unlucky with re-ordering at the start of an RTP stream? e.g. if packets 11, 10, 9 arrive in quick succession in that order we'd ignore 10 and 9. At the start of a video stream these are also likely to be part of a keyframe so their loss is particularly problematic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct

Copy link
Owner

Choose a reason for hiding this comment

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

This was already the case, so it's not better or worse.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it something we want to address long term?

Copy link
Owner

Choose a reason for hiding this comment

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

Could we detect and warn! to see how much better it'd be?

Copy link
Collaborator Author

@davibe davibe Sep 14, 2023

Choose a reason for hiding this comment

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

@k0nserv we would not ignore packets as you wrote. The comment there is from the perspective of nacking. We would not consider them for nacking.
So 11, 10, 9 is fine (no loss). An issue would be if we receive 11, 9 at the start because we would not nack 10. However even if we received 11, 10, we would not nack 9 because .. how far back should we go without knowing ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah right, this is just about nacking. Is it generally true that if the browser sends a group of packets that correspond to a frame with the sequence numbers n..=n+20 if n + 5 arrives first we will never NACK n, n + 1, n + 2, n + 3, n + 4, so if any of those are lost they are lost forever?

Copy link
Collaborator Author

@davibe davibe Sep 14, 2023

Choose a reason for hiding this comment

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

yes. also what i said before is not 100% accurate, because we also don't flush them out in RTP mode (based on the fact that the register does not return is_new: true).

Needs more thought.

Copy link
Collaborator Author

@davibe davibe Sep 14, 2023

Choose a reason for hiding this comment

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

I have made it so that the active window extends back if the packet is within capacity, or warn! otherwise

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are issues with this, I have ideas how to solve but I put it in a separate PR.

Copy link
Owner

@algesten algesten left a comment

Choose a reason for hiding this comment

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

If we are merging everything together again, I want the name register.rs :)

src/streams/register_nack.rs Show resolved Hide resolved
return None;
}

let mut nacks = vec![];
Copy link
Owner

Choose a reason for hiding this comment

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

Since this is tightly coupled to the RTCP type, I don't mind making it produce the specific type directly.

@davibe davibe force-pushed the feature/new-rx-register branch 2 times, most recently from 8cac017 to 8a2e6d4 Compare September 14, 2023 21:46
- separate nack and RR generation
- remove misorder delay
- remove probation period
- simplify handing nack to avoiding unnecessary operations
@davibe davibe force-pushed the feature/new-rx-register branch from 8a2e6d4 to c10efc5 Compare September 14, 2023 22:12
@davibe davibe force-pushed the feature/new-rx-register branch from c10efc5 to 35449b6 Compare September 14, 2023 22:16
@davibe davibe requested a review from algesten September 15, 2023 06:20
Copy link
Owner

@algesten algesten left a comment

Choose a reason for hiding this comment

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

LGTM! ✨

@davibe davibe merged commit 49a1898 into main Sep 15, 2023
10 checks passed
@davibe davibe deleted the feature/new-rx-register branch September 15, 2023 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants