-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid ewma sampling from failing on 0 duration segments. #583
Avoid ewma sampling from failing on 0 duration segments. #583
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you also add a new test in test/abr/simple_abr_manager.js to prevent a regression? You can run the tests with ./build/test.py.
@@ -54,7 +54,10 @@ shaka.abr.Ewma = function(halfLife) { | |||
*/ | |||
shaka.abr.Ewma.prototype.sample = function(weight, value) { | |||
var adjAlpha = Math.pow(this.alpha_, weight); | |||
this.estimate_ = value * (1 - adjAlpha) + adjAlpha * this.estimate_; | |||
var newEstimate = value * (1 - adjAlpha) + adjAlpha * this.estimate_; | |||
// In rare circumstances newEstimate may come out to NaN. In these |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these cases, it would be preferable to drop the sample (return early). Adding to totalWeight_ in these cases will skew future samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will do.
3a64b0d
to
b818ed7
Compare
Okay, I simply overwrote the old commit to address your feedback. Please double check that the test I have added seem appropriate. It's a rather indirect way of testing for this condition but I'm not sure how else to do it. |
Looks good to me. I'll run it through the build bot to check. |
Testing in progress... |
Failure:
|
Looks like it failed some of the linter's checks. You can run |
Testing in progress... |
All tests passed! |
This fixes a divide-by-zero that caused the estimate to become NaN. Fixes #582
Fixes #582