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

ref(QualityController) Add recovery mechanism and adjust the resolution check. #2546

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

jallamsetty1
Copy link
Member

Impl a recovery mechanism for the lastN to be increased if the cpu limitation goes away and doesn't return after increasing lastN. Also, additionally improve the calculation of the expected resolution taking simulcast stream resolutions into account.

@jallamsetty1 jallamsetty1 force-pushed the ref-qualityCOntroller branch 4 times, most recently from 05bcd23 to 43c750c Compare July 24, 2024 19:18
…on check.

Impl a recovery mechanism for the lastN to be increased if the cpu limitation goes away and doesn't return after increasing lastN. Also, additionally improve the calculation of the expected resolution taking simulcast stream resolutions into account.
Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

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

Left some comments, PTAL! Good job on adding tests for this!


if (lastN !== -1 && lastN <= MIN_LAST_N) {
// Do nothing if lastN is already set to zero, i.e., the endpoint is in audio-only mode.
Copy link
Member

Choose a reason for hiding this comment

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

We use lastN of 1 when there is some SS going on, even in audio-only mode. Should we adjust the check to be < MIN_LAST_N perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm .. it doesn't seem to be that straight forward since audio-only feature is fully implemented in the application. However, I realized that when audio-only mode is enabled, client's local video sources are muted so the stats won't be processed and when either camera or screenshare is started, the client is automatically kicked out of audio-only mode. Therefore, we don't have to make assumptions about whether client is in that mode while calculating lastN. I have removed that check all together now.

@@ -21,6 +22,10 @@ const LIMITED_BY_CPU_TIMEOUT = 60000;
// The min. value that lastN will be set to while trying to fix video qaulity issues.
const MIN_LAST_N = 3;

// Wait time to check if cpu limitation reappears after lastN rampup is attempted for recovery. If it does, all further
// attempts to bring lastN to configured channelLastN value will be blocked.
const LAST_N_RAMPUP_TIME = 60000;
Copy link
Member

Choose a reason for hiding this comment

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

Do we think we this should be configurable? Not even for our own testing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could. I will add a variable under the testing section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

let newLastN = lastN;

// If channelLastN is not set or set to -1 in config.js, the client will ramp up lastN to only up to 25.
let { channelLastN = 25 } = this._conference.options.config;
Copy link
Member

Choose a reason for hiding this comment

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

This 25 should be defined somewhere as a constant and used as the derfault everywhere.

Copy link
Member Author

@jallamsetty1 jallamsetty1 Jul 31, 2024

Choose a reason for hiding this comment

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

Yes! I was being lazy, we use this value in multiple places. I will make this a constant and default video quality settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

channelLastN = channelLastN === -1 ? 25 : channelLastN;
if (cpuLimited) {
const videoStreamsReceived = this._conference.getForwardedSources().length;
if (lastN !== -1 && lastN <= MIN_LAST_N) {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we could've done this check above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

modules/qualitycontrol/QualityController.ts Show resolved Hide resolved
modules/qualitycontrol/QualityController.ts Outdated Show resolved Hide resolved
modules/qualitycontrol/QualityController.ts Show resolved Hide resolved
modules/qualitycontrol/QualityController.ts Show resolved Hide resolved
saghul
saghul previously approved these changes Aug 5, 2024
Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of minor nits, awesome work!

*/
constructor(conference: JitsiConference, codecSettings: any, enableAdaptiveMode: boolean) {
constructor(conference: JitsiConference, options) {
Copy link
Member

Choose a reason for hiding this comment

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

type for options?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


newLastN = videoStreamsReceived / 2;
Copy link
Member

Choose a reason for hiding this comment

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

Round to the nearest integer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -380,7 +377,7 @@ export class QualityController {
trackStats: [ ssrcStats ]
};

statsPerTrack.set(track.rtcId, existingStats);
statsPerTrack.set(trackId, existingStats);
Copy link
Member

Choose a reason for hiding this comment

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

Why are we setting the string as a key, which then forces us to use .toString() everywhere?

Copy link
Member Author

@jallamsetty1 jallamsetty1 Aug 7, 2024

Choose a reason for hiding this comment

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

I initially declared the key for the encode time stats to be a string and later realized that rtcId is a number. I changed it back. At that time I thought a string made more sense if its a number/string but I see that its a number always.

Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

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

🙌

@jallamsetty1 jallamsetty1 merged commit 03eef6d into master Aug 7, 2024
2 checks passed
@jallamsetty1 jallamsetty1 deleted the ref-qualityCOntroller branch August 7, 2024 19:11
he-patrick pushed a commit to he-patrick/lib-jitsi-meet that referenced this pull request Aug 10, 2024
…on check. (jitsi#2546)

* ref(QualityController) Add recovery mechanism and adjust the resolution check.
Impl a recovery mechanism for the lastN to be increased if the cpu limitation goes away and doesn't return after increasing lastN. Also, additionally improve the calculation of the expected resolution taking simulcast stream resolutions into account.

* squash: Address review comments and add more unit tests

* squash: Address review comments
jallamsetty1 added a commit that referenced this pull request Aug 12, 2024
…on check. (#2546)

* ref(QualityController) Add recovery mechanism and adjust the resolution check.
Impl a recovery mechanism for the lastN to be increased if the cpu limitation goes away and doesn't return after increasing lastN. Also, additionally improve the calculation of the expected resolution taking simulcast stream resolutions into account.

* squash: Address review comments and add more unit tests

* squash: Address review comments
jallamsetty1 added a commit that referenced this pull request Aug 12, 2024
…on check. (#2546)

* ref(QualityController) Add recovery mechanism and adjust the resolution check.
Impl a recovery mechanism for the lastN to be increased if the cpu limitation goes away and doesn't return after increasing lastN. Also, additionally improve the calculation of the expected resolution taking simulcast stream resolutions into account.

* squash: Address review comments and add more unit tests

* squash: Address review comments
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.

2 participants