-
Notifications
You must be signed in to change notification settings - Fork 866
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
[core] Shared moving average calc for RCV and SND buffers #1348
[core] Shared moving average calc for RCV and SND buffers #1348
Conversation
5585e53
to
4e49708
Compare
Integer-based calculation of the moving average does not work well. Legend
|
|
||
if (elapsed_ms > 1000) | ||
{ | ||
// No sampling in last 1 sec, initialize average |
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.
Is assumption, that now > 1000 will always be true, safe?
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.
It is unlikely to be true. Most of the time elapsed_ms is below 1s.
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.
I mean, a situation that now
would ship a value less than 1000. Then when you subtract 0 from it you'll get the same value, and already less than 1000. If not, then the "too long time ago" situation would be handled together with "didn't initialize before".
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.
now
would ship a value less than 1000
now
is the current time. How can it ship a value of less than 1000?
Or do you mean now - m_tsLastSamplingTime
?
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.
No, I meant now
exactly - so that the result of the value compared against 1000 would be less than 1000. I personally think that even if you have a steady clock that starts from 0 at the moment when the system starts, no system in the world is capable of running the application in less than 1s after bootup.
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.
Consider ^
f54584d
to
3c9edc6
Compare
instead of ints
3c9edc6
to
f99a9b9
Compare
Saving scripts and data used for analysis. |
Both Receiver and Sender buffers share the same logic of the moving average calculation of the buffer state (packets, bytes, timespan).
This PR moves this logic into a separate class, which is used as aggregation by both buffers.
Didn't use inheritance to avoid virtual tables.
Fixes #1272