Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Unified Diff: webrtc/modules/pacing/alr_detector.cc

Issue 2503643003: More reliable ALR detection (Closed)
Patch Set: const Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/pacing/alr_detector.h ('k') | webrtc/modules/pacing/alr_detector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/pacing/alr_detector.cc
diff --git a/webrtc/modules/pacing/alr_detector.cc b/webrtc/modules/pacing/alr_detector.cc
index 677c7e018e59823faddcaafabe2c6ca804f383b4..90afe18fef76a3368d1db725e758c5d31ffee8e9 100644
--- a/webrtc/modules/pacing/alr_detector.cc
+++ b/webrtc/modules/pacing/alr_detector.cc
@@ -15,56 +15,39 @@
namespace {
-// Time period over which outgoing traffic is measured and considered a single
-// data point.
-constexpr int kMeasurementPeriodMs = 100;
+// Time period over which outgoing traffic is measured.
+constexpr int kMeasurementPeriodMs = 500;
-// Minimum number of consecutive measurements over |kMeasurementPeriodMs| time
-// that indicate sending rate is below |kUsagePercent| to consider being
-// application limited.
-constexpr int kApplicationLimitedThreshold = 5;
-
-// Sent traffic percentage as a function of network capaicty to consider traffic
-// as application limited.
+// Sent traffic percentage as a function of network capacity used to determine
+// application-limited region. ALR region start when bandwidth usage drops below
+// kAlrStartUsagePercent and ends when it raises above kAlrEndUsagePercent.
// NOTE: This is intentionally conservative at the moment until BW adjustments
// of application limited region is fine tuned.
-constexpr int kUsagePercent = 30;
+constexpr int kAlrStartUsagePercent = 30;
+constexpr int kAlrEndUsagePercent = 50;
} // namespace
namespace webrtc {
AlrDetector::AlrDetector()
- : measurement_interval_bytes_sent_(0),
- measurement_interval_elapsed_time_ms_(0),
- estimated_bitrate_bps_(0),
- application_limited_count_(0) {}
+ : rate_(kMeasurementPeriodMs, RateStatistics::kBpsScale) {}
AlrDetector::~AlrDetector() {}
-void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t elapsed_time_ms) {
- if (measurement_interval_elapsed_time_ms_ > kMeasurementPeriodMs) {
- RTC_DCHECK(estimated_bitrate_bps_);
- int max_bytes =
- (measurement_interval_elapsed_time_ms_ * estimated_bitrate_bps_) /
- (8 * 1000);
- RTC_DCHECK_GT(max_bytes, 0);
- int utilization =
- static_cast<int>((measurement_interval_bytes_sent_ * 100) / max_bytes);
- if (utilization < kUsagePercent) {
- application_limited_count_++;
- if (application_limited_count_ == kApplicationLimitedThreshold)
- LOG(LS_INFO) << "ALR start";
- } else {
- if (application_limited_count_ >= kApplicationLimitedThreshold)
- LOG(LS_INFO) << "ALR stop";
- application_limited_count_ = 0;
- }
- measurement_interval_elapsed_time_ms_ = elapsed_time_ms;
- measurement_interval_bytes_sent_ = bytes_sent;
- } else {
- measurement_interval_elapsed_time_ms_ += elapsed_time_ms;
- measurement_interval_bytes_sent_ += bytes_sent;
+void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t now_ms) {
+ RTC_DCHECK(estimated_bitrate_bps_);
+
+ rate_.Update(bytes_sent, now_ms);
+ rtc::Optional<uint32_t> rate = rate_.Rate(now_ms);
+ if (!rate)
+ return;
+
+ int percentage = static_cast<int>(*rate) * 100 / estimated_bitrate_bps_;
+ if (percentage < kAlrStartUsagePercent && !application_limited_) {
+ application_limited_ = true;
+ } else if (percentage > kAlrEndUsagePercent && application_limited_) {
+ application_limited_ = false;
}
}
@@ -73,8 +56,8 @@ void AlrDetector::SetEstimatedBitrate(int bitrate_bps) {
estimated_bitrate_bps_ = bitrate_bps;
}
-bool AlrDetector::InApplicationLimitedRegion() {
- return application_limited_count_ >= kApplicationLimitedThreshold;
+bool AlrDetector::InApplicationLimitedRegion() const {
+ return application_limited_;
}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/pacing/alr_detector.h ('k') | webrtc/modules/pacing/alr_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698