-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Refactor DelayedReader startup #771
Comments
would like to take this up! |
@gagankonana Thanks, welcome! |
Hey @gavv, I have made some updates relating to the refactoring but I am not able to figure out how to run or test the changes locally. Can you please point me in the direction of documentation on how to build and run tests? I am new to the repo and trying to understand how to set up the project locally and run tests. |
Hi, thank you for your PR You can start from this page and then all others are also nice to observe. This line works for me:
It builds everything and runs tests. As @gavv has written, all the tests should pass except those for |
@baranovmv Awesome, thank you! |
Hi @baranovmv, I was able to run the tests with your instructions but some of the tests are failing. I think the way I have implemented
|
Hi @gagankonana That's hard to say, could you please point me to a valid commit I could experiment with myself? Your recent master branch refuses to be built (f91e74) |
HI @baranovmv, sorry about that. I did not have the changes pushed up. Just pushed the updates to my master. I think my implementation of |
Haha, the issue is a bit complicated, so the changes should be more involving. In short, |
Okay, thank you for looking into it! |
Hi @gavv, I was wondering if you were able to look into it and give me more info on how to calculate the actual delay |
@gagankonana I'm sorry, I'm being sick last weeks, but I keep in mind this PR and will take a look as soon as I'll recover. Thanks for the patch! |
@gavv no worries, take care! |
Hi, sorry again for delay, and thank a lot you both for looking into it. So, LatencyMonitor needs a way to calculate NIQ latency before depacketizer is started. An obvious solution would be to get the very first packet written to incoming queue (we currently don't have method for that), as well as the very last (returned by latest() method), and calculate the difference. But the problem is that fec::BlockReader usually drops leading packets until it meets first packet in FEC block (i.e. packet with ESI=0). In result, we'll always start too early - we'll see that incoming queue have enough length and start, but then FEC reader will drop part of the packets. I found an old task related to this behavior: gh-186. It discusses various possible approaches. Originally I was trying to avoid dropping packets at all, but so far I don't see any good way to do that. Suggested solutionHowever, we can do a simpler change that will fix problems both for that task and for the current one:
This will not solve increased "cold" latency (i.e. waiting time before we meet FEC block boundary), but this will solve problems with incorrect start time. Cold latency is not so important. Implementation notesAbout FEC blocks, ESI, etc: https://roc-streaming.org/toolkit/docs/internals/fec.html Currently waiting for FEC block boundary is implemented in Note that DelayedReader should take into account possible packet reordering when waiting for the block boundary. The algorithm can be roughly the following:
If FEC is disabled, DelayedReader should set |
DelayedReader is pipeline elements that inserts initial delay in the stream, by accumulating packets until there is enough of them, and only then forwarding them.
LatencyTuner is a class that monitors and adjusts latency on fly.
Currently, they work independently. DelayedReader unconditionally inserts initial delay and then enters "normal" mode (just forwards packets through it). We want to change it, so that LatencyTuner will decide when initial delay is done and tell DelayedReader to finish delay and enter normal mode.
Steps
Rework
DelayedReader
. Removetarget_delay
parameter and instead add new methodsis_started()
andstart()
. Until start() is called,DelayedReader
accumulates packets. When it's called, it enters normal mode.Update
LatencyTuner
. Add new methodcan_start()
. It starts returning true whenactual_latency
calculated inupdate_stream()
became>= target_latency
.Update
LatencyMonitor
. It is a class that glues multiple latency-related classes together. Pass a reference to DelayedReader to LatencyMonitor. Inpre_read_()
, check if DelayedReaderis_started()
. If not, ask LatencyTuner if wecan_start()
. If yes,start()
Delay reader.After this, all tests (except unit tests for DelayedReader) should continue working without modification. roc_pipeline tests cover initial delay, so if they pass, we've done everything right.
The text was updated successfully, but these errors were encountered: