From 01d3618a75c9a3f16143ae601a2b3cc22c9f5ca6 Mon Sep 17 00:00:00 2001 From: Jonas Olsson Date: Wed, 27 Mar 2019 15:57:02 +0100 Subject: [PATCH] Make the OnMaxTotalAllocation probes configurable. This CL allows us to control how many probes we send when the bandwidth allocation is updated, and how big they are. Bug: webrtc:10394 Change-Id: I19e40740a528f83384b65d7509295034cc9a3031 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129904 Commit-Queue: Jonas Olsson Reviewed-by: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#27317} --- .../goog_cc/probe_controller.cc | 50 ++++++++++++------- .../goog_cc/probe_controller.h | 15 ++++-- .../goog_cc/probe_controller_unittest.cc | 12 ++++- 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index e5a6d1fd01..3ff96c47f5 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -91,16 +91,20 @@ void MaybeLogProbeClusterCreated(RtcEventLog* event_log, ProbeControllerConfig::ProbeControllerConfig( const WebRtcKeyValueConfig* key_value_config) - : first_exponential_probe_scale_("p1", 3.0), - second_exponential_probe_scale_("p2", 6.0), - further_exponential_probe_scale_("step_size", 2), + : first_exponential_probe_scale("p1", 3.0), + second_exponential_probe_scale("p2", 6.0), + further_exponential_probe_scale("step_size", 2), further_probe_threshold("further_probe_threshold", 0.7), - alr_probing_interval_("alr_interval", TimeDelta::seconds(5)), - alr_probe_scale_("alr_scale", 2) { + alr_probing_interval("alr_interval", TimeDelta::seconds(5)), + alr_probe_scale("alr_scale", 2), + first_allocation_probe_scale("alloc_p1", 1), + second_allocation_probe_scale("alloc_p2", 2), + allocation_allow_further_probing("alloc_probe_further", false) { ParseFieldTrial( - {&first_exponential_probe_scale_, &second_exponential_probe_scale_, - &further_exponential_probe_scale_, &further_probe_threshold, - &alr_probing_interval_, &alr_probe_scale_}, + {&first_exponential_probe_scale, &second_exponential_probe_scale, + &further_exponential_probe_scale, &further_probe_threshold, + &alr_probing_interval, &alr_probe_scale, &first_allocation_probe_scale, + &second_allocation_probe_scale, &allocation_allow_further_probing}, key_value_config->Lookup("WebRTC-Bwe-ProbingConfiguration")); } @@ -183,11 +187,19 @@ std::vector ProbeController::OnMaxTotalAllocatedBitrate( (max_bitrate_bps_ <= 0 || estimated_bitrate_bps_ < max_bitrate_bps_) && estimated_bitrate_bps_ < max_total_allocated_bitrate) { max_total_allocated_bitrate_ = max_total_allocated_bitrate; - // Also probe at 2x the max bitrate, to account for the transmission max - // bitrate multiplier functionality of the BitrateAllocator. - return InitiateProbing( - at_time_ms, - {max_total_allocated_bitrate, 2 * max_total_allocated_bitrate}, false); + + if (!config_.first_allocation_probe_scale) + return std::vector(); + + std::vector probes = { + static_cast(config_.first_allocation_probe_scale.Value() * + max_total_allocated_bitrate)}; + if (config_.second_allocation_probe_scale) { + probes.push_back(config_.second_allocation_probe_scale.Value() * + max_total_allocated_bitrate); + } + return InitiateProbing(at_time_ms, probes, + config_.allocation_allow_further_probing); } max_total_allocated_bitrate_ = max_total_allocated_bitrate; return std::vector(); @@ -216,9 +228,9 @@ std::vector ProbeController::InitiateExponentialProbing( // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of // 1.2 Mbps to continue probing. std::vector probes = {static_cast( - config_.first_exponential_probe_scale_ * start_bitrate_bps_)}; - if (config_.second_exponential_probe_scale_) { - probes.push_back(config_.second_exponential_probe_scale_.Value() * + config_.first_exponential_probe_scale * start_bitrate_bps_)}; + if (config_.second_exponential_probe_scale) { + probes.push_back(config_.second_exponential_probe_scale.Value() * start_bitrate_bps_); } return InitiateProbing(at_time_ms, probes, true); @@ -247,7 +259,7 @@ std::vector ProbeController::SetEstimatedBitrate( bitrate_bps > min_bitrate_to_probe_further_bps_) { pending_probes = InitiateProbing( at_time_ms, - {static_cast(config_.further_exponential_probe_scale_ * + {static_cast(config_.further_exponential_probe_scale * bitrate_bps)}, true); } @@ -348,11 +360,11 @@ std::vector ProbeController::Process(int64_t at_time_ms) { if (alr_start_time_ms_ && estimated_bitrate_bps_ > 0) { int64_t next_probe_time_ms = std::max(*alr_start_time_ms_, time_last_probing_initiated_ms_) + - config_.alr_probing_interval_->ms(); + config_.alr_probing_interval->ms(); if (at_time_ms >= next_probe_time_ms) { return InitiateProbing(at_time_ms, {static_cast(estimated_bitrate_bps_ * - config_.alr_probe_scale_)}, + config_.alr_probe_scale)}, true); } } diff --git a/modules/congestion_controller/goog_cc/probe_controller.h b/modules/congestion_controller/goog_cc/probe_controller.h index d0efb27d50..ebf8c94339 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.h +++ b/modules/congestion_controller/goog_cc/probe_controller.h @@ -39,14 +39,19 @@ struct ProbeControllerConfig { // Then whenever we get a bitrate estimate of at least further_probe_threshold // times the size of the last sent probe we'll send another one of size // step_size times the new estimate. - FieldTrialParameter first_exponential_probe_scale_; - FieldTrialOptional second_exponential_probe_scale_; - FieldTrialParameter further_exponential_probe_scale_; + FieldTrialParameter first_exponential_probe_scale; + FieldTrialOptional second_exponential_probe_scale; + FieldTrialParameter further_exponential_probe_scale; FieldTrialParameter further_probe_threshold; // Configures how often we send ALR probes and how big they are. - FieldTrialParameter alr_probing_interval_; - FieldTrialParameter alr_probe_scale_; + FieldTrialParameter alr_probing_interval; + FieldTrialParameter alr_probe_scale; + + // Configures the probes emitted by changed to the allocated bitrate. + FieldTrialOptional first_allocation_probe_scale; + FieldTrialOptional second_allocation_probe_scale; + FieldTrialFlag allocation_allow_further_probing; }; // This class controls initiation of probing to estimate initial channel diff --git a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc index 7aba8e1374..46b661cb53 100644 --- a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc @@ -315,11 +315,12 @@ TEST_F(ProbeControllerTest, TestAllocatedBitrateCap) { TEST_F(ProbeControllerTest, ConfigurableProbingFieldTrial) { test::ScopedFieldTrials trials( "WebRTC-Bwe-ProbingConfiguration/" - "p1:2,p2:5,step_size:3,further_probe_threshold:0.8/"); + "p1:2,p2:5,step_size:3,further_probe_threshold:0.8," + "alloc_p1:2,alloc_p2/"); probe_controller_.reset( new ProbeController(&field_trial_config_, &mock_rtc_event_log)); auto probes = probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, - kMaxBitrateBps, NowMs()); + 5000000, NowMs()); EXPECT_EQ(probes.size(), 2u); EXPECT_EQ(probes[0].target_data_rate.bps(), 600); EXPECT_EQ(probes[1].target_data_rate.bps(), 1500); @@ -332,6 +333,13 @@ TEST_F(ProbeControllerTest, ConfigurableProbingFieldTrial) { probes = probe_controller_->SetEstimatedBitrate(1250, NowMs()); EXPECT_EQ(probes.size(), 1u); EXPECT_EQ(probes[0].target_data_rate.bps(), 3 * 1250); + + clock_.AdvanceTimeMilliseconds(5000); + probes = probe_controller_->Process(NowMs()); + + probes = probe_controller_->OnMaxTotalAllocatedBitrate(200000, NowMs()); + EXPECT_EQ(probes.size(), 1u); + EXPECT_EQ(probes[0].target_data_rate.bps(), 400000); } } // namespace test