Skip to content

Commit

Permalink
Make bandwidth estimator cache friendly.
Browse files Browse the repository at this point in the history
Closes #324

Change-Id: Ie01be560c607c77c116ac7bcea18efe081526d61
  • Loading branch information
TheModMaker committed Apr 21, 2016
1 parent cc243fa commit 60d2944
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/abr/ewma_bandwidth_estimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ shaka.abr.EwmaBandwidthEstimator = function() {
* @const
*/
this.minBytes_ = 65536;


/**
* Minimum amount of time (in ms), under which samples are discarded.
* @private {number}
* @const
*/
this.minTime_ = 200;
};


Expand All @@ -90,7 +98,11 @@ shaka.abr.EwmaBandwidthEstimator.DEFAULT_ESTIMATE = 5e5; // 500kbps
*/
shaka.abr.EwmaBandwidthEstimator.prototype.sample = function(
durationMs, numBytes) {
if (numBytes < this.minBytes_) {
// Ignore small requests. This will protect against both caching and
// outliers. Small requests in size will tend to vary a lot in the time they
// take, and overhead of JavaScript timings have a big effect. Also, cached
// responses will always return in a small time.
if (numBytes < this.minBytes_ || durationMs < this.minTime_) {
return;
}

Expand Down

0 comments on commit 60d2944

Please sign in to comment.