Avoid ewma sampling from failing on 0 duration segments.#583
Conversation
joeyparrish
left a comment
There was a problem hiding this comment.
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.
lib/abr/ewma.js
Outdated
| 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.
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.
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