From 3821ff8df57e8d9622b13ea0636bf833ab4733a4 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 4 Sep 2016 05:07:26 -0700 Subject: [PATCH] Only log BWE updates if the actual estimate changed or if we have non-zero loss reports. BUG=webrtc:6295 Review-Url: https://codereview.webrtc.org/2306963002 Cr-Commit-Position: refs/heads/master@{#14061} --- .../send_side_bandwidth_estimation.cc | 24 ++++++++++++------- .../send_side_bandwidth_estimation.h | 2 ++ ...send_side_bandwidth_estimation_unittest.cc | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index e47d4917e9..7d9d5c3be6 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -29,6 +29,7 @@ const int kLimitNumPackets = 20; const int kDefaultMinBitrateBps = 10000; const int kDefaultMaxBitrateBps = 1000000000; const int64_t kLowBitrateLogPeriodMs = 10000; +const int64_t kRtcEventLogPeriodMs = 5000; struct UmaRampUpMetric { const char* metric_name; @@ -54,6 +55,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) has_decreased_since_last_fraction_loss_(false), time_last_receiver_block_ms_(-1), last_fraction_loss_(0), + last_logged_fraction_loss_(0), last_round_trip_time_ms_(0), bwe_incoming_(0), delay_based_bitrate_bps_(0), @@ -63,7 +65,8 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) bitrate_at_2_seconds_kbps_(0), uma_update_state_(kNoUpdate), rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), - event_log_(event_log) { + event_log_(event_log), + last_rtc_event_log_ms_(-1) { RTC_DCHECK(event_log); } @@ -228,10 +231,6 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { // (gives a little extra increase at low rates, negligible at higher // rates). bitrate_ += 1000; - - event_log_->LogBwePacketLossEvent( - bitrate_, last_fraction_loss_, - expected_packets_since_last_loss_update_); } else if (last_fraction_loss_ <= 26) { // Loss between 2% - 10%: Do nothing. } else { @@ -250,12 +249,19 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { 512.0); has_decreased_since_last_fraction_loss_ = true; } - event_log_->LogBwePacketLossEvent( - bitrate_, last_fraction_loss_, - expected_packets_since_last_loss_update_); } } - bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); + uint32_t capped_bitrate = CapBitrateToThresholds(now_ms, bitrate_); + if (capped_bitrate != bitrate_ || + last_fraction_loss_ != last_logged_fraction_loss_ || + last_rtc_event_log_ms_ == -1 || + now_ms - last_rtc_event_log_ms_ > kRtcEventLogPeriodMs) { + event_log_->LogBwePacketLossEvent(capped_bitrate, last_fraction_loss_, + expected_packets_since_last_loss_update_); + last_logged_fraction_loss_ = last_fraction_loss_; + last_rtc_event_log_ms_ = now_ms; + } + bitrate_ = capped_bitrate; } bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h index c97714f7e8..dc9de10f7f 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -84,6 +84,7 @@ class SendSideBandwidthEstimation { bool has_decreased_since_last_fraction_loss_; int64_t time_last_receiver_block_ms_; uint8_t last_fraction_loss_; + uint8_t last_logged_fraction_loss_; int64_t last_round_trip_time_ms_; uint32_t bwe_incoming_; @@ -95,6 +96,7 @@ class SendSideBandwidthEstimation { UmaState uma_update_state_; std::vector rampup_uma_stats_updated_; RtcEventLog* event_log_; + int64_t last_rtc_event_log_ms_; }; } // namespace webrtc #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc index 64cb2fee51..12f8603068 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc @@ -67,7 +67,7 @@ TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { MockRtcEventLog event_log; EXPECT_CALL(event_log, LogBwePacketLossEvent(testing::Gt(0), testing::Gt(0), 0)) - .Times(3); + .Times(1); SendSideBandwidthEstimation bwe(&event_log); static const int kMinBitrateBps = 100000; static const int kInitialBitrateBps = 1000000;