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

Fix bandwidth probation dead state #1031

Merged
merged 3 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ AlrDetector::AlrDetector(
experiment_settings
? experiment_settings->alr_stop_budget_level_percent / 100.0
: kDefaultStopBudgetLevelRatio),
alr_timeout_(
"alr_timeout",
experiment_settings
? experiment_settings->alr_timeout
: kDefaultAlrTimeout),
alr_budget_(0, true) {
ParseFieldTrial({&bandwidth_usage_ratio_, &start_budget_level_ratio_,
&stop_budget_level_ratio_},
Expand All @@ -73,7 +78,7 @@ AlrDetector::~AlrDetector() {}
void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t send_time_ms) {
if (!last_send_time_ms_.has_value()) {
last_send_time_ms_ = send_time_ms;
// Since the duration for sending the bytes is unknwon, return without
// Since the duration for sending the bytes is unknown, return without
// updating alr state.
return;
}
Expand Down Expand Up @@ -109,4 +114,18 @@ absl::optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
return alr_started_time_ms_;
}

absl::optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime(
int64_t at_time_ms) {
if (!alr_started_time_ms_ && *last_send_time_ms_) {
int64_t delta_time_ms = at_time_ms - *last_send_time_ms_;
// If ALR is stopped and we haven't sent any packets for a while, force start.
if (delta_time_ms > alr_timeout_) {
MS_WARN_TAG(bwe, "large delta_time_ms: %ld, forcing alr state change",
delta_time_ms);
alr_started_time_ms_.emplace(at_time_ms);
}
}
return alr_started_time_ms_;
}

} // namespace webrtc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AlrDetector {
// Returns time in milliseconds when the current application-limited region
// started or empty result if the sender is currently not application-limited.
absl::optional<int64_t> GetApplicationLimitedRegionStartTime() const;
absl::optional<int64_t> GetApplicationLimitedRegionStartTime(int64_t at_time_ms);

void UpdateBudgetWithElapsedTime(int64_t delta_time_ms);
void UpdateBudgetWithBytesSent(size_t bytes_sent);
Expand All @@ -56,6 +57,7 @@ class AlrDetector {
static constexpr double kDefaultBandwidthUsageRatio = 0.65;
static constexpr double kDefaultStartBudgetLevelRatio = 0.80;
static constexpr double kDefaultStopBudgetLevelRatio = 0.50;
static constexpr int kDefaultAlrTimeout = 3000;

AlrDetector(const WebRtcKeyValueConfig* key_value_config,
absl::optional<AlrExperimentSettings> experiment_settings);
Expand All @@ -64,6 +66,7 @@ class AlrDetector {
FieldTrialParameter<double> bandwidth_usage_ratio_;
FieldTrialParameter<double> start_budget_level_ratio_;
FieldTrialParameter<double> stop_budget_level_ratio_;
FieldTrialParameter<int> alr_timeout_;

absl::optional<int64_t> last_send_time_ms_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval(
}
bandwidth_estimation_->UpdateEstimate(msg.at_time);
absl::optional<int64_t> start_time_ms =
alr_detector_->GetApplicationLimitedRegionStartTime();
alr_detector_->GetApplicationLimitedRegionStartTime(msg.at_time.ms());
probe_controller_->SetAlrStartTimeMs(start_time_ms);

auto probes = probe_controller_->Process(msg.at_time.ms());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char AlrExperimentSettings::kScreenshareProbingBweExperimentName[] =
"WebRTC-ProbingScreenshareBwe";
const char AlrExperimentSettings::kStrictPacingAndProbingExperimentName[] =
"WebRTC-StrictPacingAndProbing";
const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3";
const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3,3000";

bool AlrExperimentSettings::MaxOneFieldTrialEnabled() {
return AlrExperimentSettings::MaxOneFieldTrialEnabled(
Expand Down Expand Up @@ -71,26 +71,29 @@ AlrExperimentSettings::CreateFromFieldTrial(
}

AlrExperimentSettings settings;
if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d",
if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d,%d",
&settings.pacing_factor, &settings.max_paced_queue_time,
&settings.alr_bandwidth_usage_percent,
&settings.alr_start_budget_level_percent,
&settings.alr_stop_budget_level_percent,
&settings.group_id) == 6) {
&settings.group_id,
&settings.alr_timeout) == 7) {
ret.emplace(settings);
MS_DEBUG_TAG(bwe, "Using ALR experiment settings: "
"pacing factor: %f"
", max pacer queue length:%" PRIi64
", ALR bandwidth usage percent: %d"
", ALR start budget level percent: %d"
", ALR end budget level percent: %d"
", ALR experiment group ID: %d",
", ALR experiment group ID: %d"
", ALR timeout: %d",
settings.pacing_factor,
settings.max_paced_queue_time,
settings.alr_bandwidth_usage_percent,
settings.alr_start_budget_level_percent,
settings.alr_stop_budget_level_percent,
settings.group_id);
settings.group_id,
settings.alr_timeout);
} else {
MS_DEBUG_TAG(bwe, "Failed to parse ALR experiment: %s", experiment_name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct AlrExperimentSettings {
int alr_bandwidth_usage_percent;
int alr_start_budget_level_percent;
int alr_stop_budget_level_percent;
int alr_timeout;
// Will be sent to the receive side for stats slicing.
// Can be 0..6, because it's sent as a 3 bits value and there's also
// reserved value to indicate absence of experiment.
Expand Down