PT-2536 - Correct EMA calculation for WeightedAvgRate internal averages#1127
Open
marcelohpf wants to merge 2 commits into
Open
PT-2536 - Correct EMA calculation for WeightedAvgRate internal averages#1127marcelohpf wants to merge 2 commits into
marcelohpf wants to merge 2 commits into
Conversation
Average number of rows and average time taken to process rows are convergent to the average by adding the 1-weight to the calculation. Previous calculation was divergent and a not correct implementation of ewma The result of update() is not affected due to the proportional calculation of number-rows/time-taken
53bc027 to
03fb408
Compare
Collaborator
|
Also tracked in Jira at https://perconadev.atlassian.net/browse/PT-2536 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Average number of rows and average time taken to process rows are convergent to the average by adding the 1-weight to the calculation.
Previous calculation was divergent and a not correct implementation of ema (Exponential Moving Average);
The result of update() is not affected due to the proportional calculation of number-rows/time-taken
You can verify the behavior of current calculation with :
Root cause
The current calculation of average number of rows (avg_n) and average time (avg_t) seems to implement an smoothing algorithm to add some lag into the average convergence to protect estimation form sudden changes in a single datapoint, but also offer a faster convergence to that value on the long dataset (100+ data-points).
However, the current calculation is divergent serie because it does not apply a reduction factor to new data point every iteration.
As consequence, the avg_n and avg_t will increase forever and never converge to the "most common representative value";
Current formula is (avg * accumulative-factor) + new-value;
When it should be (avg * accumulative-factor) + (new-value * smooth-factor);