[core] New moving average value for sent/recv rates over last second#3009
[core] New moving average value for sent/recv rates over last second#3009ethouris merged 13 commits intoHaivision:devfrom
Conversation
|
|
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 |
maxsharabayko
left a comment
There was a problem hiding this comment.
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.
!!! Division by zero not prevented!
There was a problem hiding this comment.
It is :) We don't go in the computeAverageValue method if iSampleDeltaIdx == 0.
There was a problem hiding this comment.
[ 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:4338There was a problem hiding this comment.
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.
|
IMPORTANT : this PR was merged to a trial development branch, but this branch had to be abandoned as this PR has instroduced bugs resulting in random crashes. PR #3193 restores these changes, but the code must be fixed first. |
fixes #1812 - A new class was created to compute received and sent average rates for last second, independent of the call interval.