From 3e42a8a56acaf48cccbe82003bbc1d0723a54732 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Thu, 15 Jan 2015 14:45:27 +0000 Subject: [PATCH] Add UMA stats for tracking the time it takes to reach a BWE of 500, 1000 and 2000 kbps. BUG=crbug:425925 R=asapersson@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41529004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8076 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../send_side_bandwidth_estimation.cc | 32 ++++++++++++++++--- .../send_side_bandwidth_estimation.h | 1 + 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index a08e12300..46fc1c920 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -25,6 +25,18 @@ enum { kAvgPacketSizeBytes = 1000 }; enum { kStartPhaseMs = 2000 }; enum { kBweConverganceTimeMs = 20000 }; +struct UmaRampUpMetric { + std::string metric_name; + int bitrate_kbps; +}; + +const UmaRampUpMetric kUmaRampupMetrics[] = { + {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, + {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, + {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; +const size_t kNumUmaRampupMetrics = + sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]); + // Calculate the rate that TCP-Friendly Rate Control (TFRC) would apply. // The formula in RFC 3448, Section 3.1, is used. uint32_t CalcTfrcBps(int64_t rtt, uint8_t loss) { @@ -50,6 +62,7 @@ uint32_t CalcTfrcBps(int64_t rtt, uint8_t loss) { } } + SendSideBandwidthEstimation::SendSideBandwidthEstimation() : accumulate_lost_packets_Q8_(0), accumulate_expected_packets_(0), @@ -64,7 +77,8 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation() first_report_time_ms_(-1), initially_lost_packets_(0), bitrate_at_2_seconds_kbps_(0), - uma_update_state_(kNoUpdate) { + uma_update_state_(kNoUpdate), + rampup_uma_stats_updated_(kNumUmaRampupMetrics, false) { } SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} @@ -139,11 +153,20 @@ void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms, int64_t rtt, int lost_packets) { + int bitrate_kbps = static_cast((bitrate_ + 500) / 1000); + for (size_t i = 0; i < kNumUmaRampupMetrics; ++i) { + if (!rampup_uma_stats_updated_[i] && + bitrate_kbps >= kUmaRampupMetrics[i].bitrate_kbps) { + RTC_HISTOGRAM_COUNTS_100000(kUmaRampupMetrics[i].metric_name, + now_ms - first_report_time_ms_); + rampup_uma_stats_updated_[i] = true; + } + } if (IsInStartPhase(now_ms)) { initially_lost_packets_ += lost_packets; } else if (uma_update_state_ == kNoUpdate) { uma_update_state_ = kFirstDone; - bitrate_at_2_seconds_kbps_ = (bitrate_ + 500) / 1000; + bitrate_at_2_seconds_kbps_ = bitrate_kbps; RTC_HISTOGRAM_COUNTS( "WebRTC.BWE.InitiallyLostPackets", initially_lost_packets_, 0, 100, 50); RTC_HISTOGRAM_COUNTS( @@ -156,9 +179,8 @@ void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms, } else if (uma_update_state_ == kFirstDone && now_ms - first_report_time_ms_ >= kBweConverganceTimeMs) { uma_update_state_ = kDone; - int bitrate_diff_kbps = std::max( - bitrate_at_2_seconds_kbps_ - static_cast((bitrate_ + 500) / 1000), - 0); + int bitrate_diff_kbps = + std::max(bitrate_at_2_seconds_kbps_ - bitrate_kbps, 0); RTC_HISTOGRAM_COUNTS( "WebRTC.BWE.InitialVsConvergedDiff", bitrate_diff_kbps, 0, 2000, 50); } diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h index 20ce5ee3a..427909b3e 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -81,6 +81,7 @@ class SendSideBandwidthEstimation { int initially_lost_packets_; int bitrate_at_2_seconds_kbps_; UmaState uma_update_state_; + std::vector rampup_uma_stats_updated_; }; } // namespace webrtc #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_