Skip to content

Preparation for E2E latency tuning - #786

Merged
gavv merged 7 commits into
roc-streaming:developfrom
baranovmv:feature/rtcp_rts
Aug 24, 2026
Merged

Preparation for E2E latency tuning#786
gavv merged 7 commits into
roc-streaming:developfrom
baranovmv:feature/rtcp_rts

Conversation

@baranovmv

@baranovmv baranovmv commented Dec 4, 2024

Copy link
Copy Markdown
Member

gh-127

In order to be able to tune receiver's latency
relying on timestamp mapping that we get from
RTCP feedback, and UDP::Receive_timestamp,
adding these features:

  • RTCP improvements #674: Use receive timestamp (RTS) as report time when processing RTCP report;

  • RTT dumping for debugging (csvplotter ts_offset branch);

  • SCHED_RR for network io thread (run with root privs).

@baranovmv
baranovmv requested a review from gavv December 4, 2024 23:10
@github-actions github-actions Bot added the S-ready-for-review status: PR can be reviewed label Dec 4, 2024
@baranovmv
baranovmv force-pushed the feature/rtcp_rts branch 6 times, most recently from bc3295d to 99c8903 Compare December 12, 2024 17:25
@baranovmv
baranovmv force-pushed the feature/rtcp_rts branch 2 times, most recently from a475567 to 5e85289 Compare December 19, 2024 21:41
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot added the S-needs-rebase status: PR has conflicts and should be rebased label Jan 16, 2025

@gavv gavv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow, this is big.

I like the approach you use for RTS (set early when possible, set later as a fallback).

Comment thread src/internal_modules/roc_core/target_posix/roc_core/thread.cpp Outdated
Comment thread src/tests/roc_rtcp/test_communicator.cpp Outdated
Comment thread src/internal_modules/roc_netio/target_libuv/roc_netio/network_loop.cpp Outdated
Comment thread src/internal_modules/roc_rtcp/rtt_estimator.h Outdated
if ((code = repair_endpoint_->pull_packets(0)) != status::StatusOK) {
return code;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment as for receiver slot.

@baranovmv baranovmv Feb 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I support your thought, but it will make pipeline tests dependent on real-time speed.

So far, LatencyMonitor calls core::timestamp(core::ClockUnix) when it computes latency_metrics_.niq_stalling. If we will set receive timestamp on all passing packets (which is your proposition here), we could not tell the difference between test and real use scenario. In order to pass these tests, I've set base_cts to current timestamp:

diff --git a/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp
index 4c47930e..2d7e188c 100644
--- a/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp
+++ b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp
@@ -569,7 +569,7 @@ void send_receive(int flags,
     core::nanoseconds_t virtual_e2e_latency = 0;
 
     if (flags & FlagCTS) {
-        send_base_cts = 1000000000000000;
+        send_base_cts = core::timestamp(core::ClockUnix);
         virtual_e2e_latency = core::Millisecond * 100;
     }

In receiver_source test latency_lower_bound I had to do the same.

Please, take a look onto 6bd629e

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So, I propose to hold this change, until (if) we decide to introduce mock for core::timestamp(...) in pipeline tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, I see. That's not good but I agree that it's outside of scope of this PR. I'll try to take a look at it later, will add it to my todo. Let's follow your proposal then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've reverted these changes for the time being

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It was actually very easy fix: 05ab131

Comment thread src/internal_modules/roc_pipeline/receiver_slot.cpp
Comment thread src/internal_modules/roc_rtcp/rtt_estimator.cpp Outdated
Comment thread src/tests/roc_rtcp/test_communicator.cpp
gavv

This comment was marked as duplicate.

@gavv

This comment was marked as resolved.

@gavv gavv added S-needs-revision status: Author should revise PR and address feedback and removed S-ready-for-review status: PR can be reviewed labels Jan 16, 2025
@roc-streaming roc-streaming deleted a comment from MishaBaranov Feb 1, 2025
@github-actions github-actions Bot removed the S-needs-rebase status: PR has conflicts and should be rebased label Feb 1, 2025
@github-actions github-actions Bot added the S-needs-rebase status: PR has conflicts and should be rebased label Feb 7, 2025
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the S-needs-rebase status: PR has conflicts and should be rebased label Feb 9, 2025
@gavv gavv added S-ready-for-review status: PR can be reviewed and removed S-needs-revision status: Author should revise PR and address feedback labels Feb 11, 2025
@gavv gavv added S-work-in-progress status: PR is still in progress and changing and removed S-ready-for-review status: PR can be reviewed labels Feb 20, 2025
@baranovmv
baranovmv force-pushed the feature/rtcp_rts branch 2 times, most recently from 516ed74 to e211975 Compare March 19, 2025 00:09
@gavv gavv added S-ready-for-review status: PR can be reviewed and removed S-work-in-progress status: PR is still in progress and changing labels Mar 23, 2025
@rocstreaming-bot rocstreaming-bot added the S-needs-rebase status: PR has conflicts and should be rebased label Jun 5, 2025
@rocstreaming-bot

This comment was marked as resolved.

@gavv gavv added S-review-in-progress status: PR is being reviewed and removed S-ready-for-review status: PR can be reviewed labels Jun 18, 2025
@rocstreaming-bot rocstreaming-bot removed the S-needs-rebase status: PR has conflicts and should be rebased label Jan 16, 2026
@baranovmv

Copy link
Copy Markdown
Member Author

@gavv "No conflicts with base branch" -- no excuses to not merge it?

I removed the commit where I deleted public-api tests, don't remember reason for that to exist.

In order to be able to tune receiver's latency
relying on timestamp mapping that we get from
RTCP feedback, and UDP::Receive_timestamp,
adding these features:

* roc-streaminggh-674: Use receive timestamp (RTS) as report time
  when processing RTCP report;

* RTT dumping for debugging (csvplotter ts_offset branch);

* SCHED_RR for network io thread (run with root privs).
@gavv
gavv force-pushed the feature/rtcp_rts branch from 2bf7513 to a388bda Compare August 24, 2026 13:03
gavv added 4 commits August 24, 2026 23:52
1. Don't use LogError in utility code because only upper
   layer decides if it's actually an error.

2. Remove StatusFailedRealtime, we already have StatusErrThread
   for thread setup failures.

3. Rename capture_ts -> receive_ts for consistency.

4. Cleanup log messages, log levels, typos.
Bare parameters don't scale well - tests already became polluted with
DEFAULT_PRIORITY, adding more params will add more noise.

So introduce the usual config struct for NetworkLoop and replace
DEFAULT_PRIORITY with default value of its field.
Similar to NetworkConfig::realtime_prio, add IoConfig::realtime_prio.
Add new group "Perf options" and move --real-time flag there.
@gavv gavv added this to the 0.5.0 milestone Aug 24, 2026
Pass current time from pipeline to from refresh(), called before
every frame read.

Integration tests already pass virtual time to pipeline refresh(),
so LatencyMonitor automatically starts working with proper time.
@rocstreaming-bot rocstreaming-bot added S-needs-revision status: Author should revise PR and address feedback and removed S-review-in-progress status: PR is being reviewed labels Aug 24, 2026
@gavv

gavv commented Aug 24, 2026

Copy link
Copy Markdown
Member

LGTM, rebased on fresh develop & pushed a few refactorings & fixes:

@gavv gavv removed the S-needs-revision status: Author should revise PR and address feedback label Aug 24, 2026
@gavv
gavv force-pushed the feature/rtcp_rts branch from 05ab131 to 39f07d9 Compare August 24, 2026 16:27
@gavv
gavv merged commit 9cfc616 into roc-streaming:develop Aug 24, 2026
47 checks passed
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