-
Notifications
You must be signed in to change notification settings - Fork 863
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] New moving average value for sent/recv rates over last second #3009
base: master
Are you sure you want to change the base?
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.
Please use formatting from the .clang-format
file in the root of the project.
|
A pacing file for srt-xtransmit with the following sending rate loop:
Usage: srt-xtransmit generate --playback-csv pacing.csv --duration 20s srt://ip:port --statsfreq 5s --statsfile test-freq5s-snd.csv |
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.
CMovingRateEstimator::addSample(int pkts, double bytes)
is quite similar to CSndRateEstimator::addSample
, but done more nicely and compact.
The main difference I see between the two classes if in how the current rate is calculated. In particular, how not full sampling period participates in rate estimation.
The CMovingRateEstimator
just uses the value as it is. It is ok because the sampling interval is 10 ms. The CSndRateEstimator
applies a filter:
(rate + 15 * sample_bytes) / 16
to be more sensitive to the newer 100 ms sampling period. Because the estimation is then used for retransmission rate estimation and limiting the retransmission if certain limit is exceeded. BTW this filtering is not necessarily correct.
So potentially both lasses could be merged if switching to a finer 10 ms sampling is ok for the retransmission rate estimation (I guess it is ok).
srtcore/buffer_tools.cpp
Outdated
newRateBps += (m_Samples[i].m_iBytesCount + (CPacket::HDR_SIZE * m_Samples[i].m_iPktsCount)); | ||
|
||
if (isFirstPeriod) | ||
newRateBps = newRateBps * 1000 / startDelta; |
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.
!!! Division by zero not prevented!
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 :) We don't go in the computeAverageValue method if iSampleDeltaIdx == 0.
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.
[ RUN ] TestSocketOptions.LossMaxTTL
/home/travis/.travis/functions: line 109: 7133 Floating point exception(core dumped) ./test-srt -disable-ipv6
[New LWP 7133]
[New LWP 7746]
[New LWP 7749]
[New LWP 7750]
[New LWP 7745]
[New LWP 7747]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./test-srt -disable-ipv6'.
Program terminated with signal SIGFPE, Arithmetic exception.
#0 0x000000000087cafc in srt::CMovingRateEstimator::computeAverageValue (this=0x7fe6bc005cb8) at /home/travis/build/Haivision/srt/srtcore/buffer_tools.cpp:334
334 newRateBps = newRateBps * 1000 / startDelta;
[Current thread is 1 (Thread 0x7fe6c9ee9740 (LWP 7133))]
#0 0x000000000087cafc in srt::CMovingRateEstimator::computeAverageValue (this=0x7fe6bc005cb8) at /home/travis/build/Haivision/srt/srtcore/buffer_tools.cpp:334
#1 0x000000000087c94d in srt::CMovingRateEstimator::addSample (this=0x7fe6bc005cb8, pkts=0, bytes=0) at /home/travis/build/Haivision/srt/srtcore/buffer_tools.cpp:313
#2 0x00000000008d80bb in srt::stats::Sender::updateRate (this=0x7fe6bc005c18, pkts=0, bytes=0) at /home/travis/build/Haivision/srt/srtcore/stats.h:174
#3 0x00000000008b934a in srt::CUDT::bstats (this=0x7fe6bc000938, perf=0x7ffd64377750, clear=false, instantaneous=false) at /home/travis/build/Haivision/srt/srtcore/core.cpp:7577
#4 0x000000000085bfe3 in srt::CUDT::bstats (u=412356694, perf=0x7ffd64377750, clear=false, instantaneous=false) at /home/travis/build/Haivision/srt/srtcore/api.cpp:4338
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 :) We don't go in the computeAverageValue method if iSampleDeltaIdx == 0.
The division by 0 is made using the value that is calculated out of the present time taken exactly in this function, so there's even no possibility that you could control this value this way.
fixes #1812 - A new class was created to compute received and sent average rates for last second, independent of the call interval.