diff options
author | ANAND <ClobberXD@gmail.com> | 2019-02-16 05:09:22 +0530 |
---|---|---|
committer | Paramat <paramat@users.noreply.github.com> | 2019-02-15 23:39:22 +0000 |
commit | 7a0e52acd65e7097977c924f26b387ec3da9baac (patch) | |
tree | 4d61197820480c17b4d032c07b64e23d93334c88 /src/network/connection.cpp | |
parent | 2153163cbd0a57783e646523c62e83bfe1be2277 (diff) | |
download | minetest-7a0e52acd65e7097977c924f26b387ec3da9baac.tar.gz minetest-7a0e52acd65e7097977c924f26b387ec3da9baac.tar.bz2 minetest-7a0e52acd65e7097977c924f26b387ec3da9baac.zip |
Revert RTT fixes (#8187)
The reverted commit 968ce9af598024ec71e9ffb2d15c3997a13ad754
is suspected (through the use of bisection) of causing network slowdowns.
Revert for now as we are close to release.
Diffstat (limited to 'src/network/connection.cpp')
-rw-r--r-- | src/network/connection.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp index 495b15426..28084c921 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -809,9 +809,8 @@ void Peer::DecUseCount() delete this; } -void Peer::RTTStatistics(float rtt, const std::string &profiler_id) -{ - static const float avg_factor = 100.0f / MAX_RELIABLE_WINDOW_SIZE; +void Peer::RTTStatistics(float rtt, const std::string &profiler_id, + unsigned int num_samples) { if (m_last_rtt > 0) { /* set min max values */ @@ -822,14 +821,21 @@ void Peer::RTTStatistics(float rtt, const std::string &profiler_id) /* do average calculation */ if (m_rtt.avg_rtt < 0.0) - m_rtt.avg_rtt = rtt; + m_rtt.avg_rtt = rtt; else - m_rtt.avg_rtt += (rtt - m_rtt.avg_rtt) * avg_factor; + m_rtt.avg_rtt = m_rtt.avg_rtt * (num_samples/(num_samples-1)) + + rtt * (1/num_samples); /* do jitter calculation */ //just use some neutral value at beginning - float jitter = std::fabs(rtt - m_last_rtt); + float jitter = m_rtt.jitter_min; + + if (rtt > m_last_rtt) + jitter = rtt-m_last_rtt; + + if (rtt <= m_last_rtt) + jitter = m_last_rtt - rtt; if (jitter < m_rtt.jitter_min) m_rtt.jitter_min = jitter; @@ -837,9 +843,10 @@ void Peer::RTTStatistics(float rtt, const std::string &profiler_id) m_rtt.jitter_max = jitter; if (m_rtt.jitter_avg < 0.0) - m_rtt.jitter_avg = jitter; + m_rtt.jitter_avg = jitter; else - m_rtt.jitter_avg += (jitter - m_rtt.jitter_avg) * avg_factor; + m_rtt.jitter_avg = m_rtt.jitter_avg * (num_samples/(num_samples-1)) + + jitter * (1/num_samples); if (!profiler_id.empty()) { g_profiler->graphAdd(profiler_id + "_rtt", rtt); @@ -904,12 +911,16 @@ bool UDPPeer::getAddress(MTProtocols type,Address& toset) void UDPPeer::reportRTT(float rtt) { - assert(rtt >= 0.0f); - - RTTStatistics(rtt, "rudp"); + if (rtt < 0.0) { + return; + } + RTTStatistics(rtt,"rudp",MAX_RELIABLE_WINDOW_SIZE*10); float timeout = getStat(AVG_RTT) * RESEND_TIMEOUT_FACTOR; - timeout = rangelim(timeout, RESEND_TIMEOUT_MIN, RESEND_TIMEOUT_MAX); + if (timeout < RESEND_TIMEOUT_MIN) + timeout = RESEND_TIMEOUT_MIN; + if (timeout > RESEND_TIMEOUT_MAX) + timeout = RESEND_TIMEOUT_MAX; MutexAutoLock usage_lock(m_exclusive_access_mutex); resend_timeout = timeout; |