Update mbps data block after terminating connection.

This commit is contained in:
Bartosz Taudul 2020-04-29 02:36:38 +02:00
parent 4634c5cdd3
commit 8fa0a4dc9e
2 changed files with 19 additions and 8 deletions

View File

@ -3018,14 +3018,7 @@ void Worker::Exec()
enum { MbpsUpdateTime = 200 };
if( td > MbpsUpdateTime )
{
const auto bytes = m_bytes.exchange( 0, std::memory_order_relaxed );
const auto decBytes = m_decBytes.exchange( 0, std::memory_order_relaxed );
std::lock_guard<std::shared_mutex> lock( m_mbpsData.lock );
m_mbpsData.mbps.erase( m_mbpsData.mbps.begin() );
m_mbpsData.mbps.emplace_back( bytes / ( td * 125.f ) );
m_mbpsData.compRatio = float( bytes ) / decBytes;
m_mbpsData.queue = m_serverQueryQueue.size();
m_mbpsData.transferred += bytes;
UpdateMbps( td );
t0 = t1;
}
@ -3053,6 +3046,7 @@ void Worker::Exec()
if( !done ) continue;
}
QueryTerminate();
UpdateMbps( 0 );
break;
}
}
@ -3064,6 +3058,21 @@ close:
m_connected.store( false, std::memory_order_relaxed );
}
void Worker::UpdateMbps( int64_t td )
{
const auto bytes = m_bytes.exchange( 0, std::memory_order_relaxed );
const auto decBytes = m_decBytes.exchange( 0, std::memory_order_relaxed );
std::lock_guard<std::shared_mutex> lock( m_mbpsData.lock );
if( td != 0 )
{
m_mbpsData.mbps.erase( m_mbpsData.mbps.begin() );
m_mbpsData.mbps.emplace_back( bytes / ( td * 125.f ) );
}
m_mbpsData.compRatio = float( bytes ) / decBytes;
m_mbpsData.queue = m_serverQueryQueue.size();
m_mbpsData.transferred += bytes;
}
bool Worker::IsThreadStringRetrieved( uint64_t id )
{
const auto name = GetThreadName( m_failureData.thread );

View File

@ -735,6 +735,8 @@ private:
tracy_force_inline ZoneExtra& AllocZoneExtra( ZoneEvent& ev );
tracy_force_inline ZoneExtra& RequestZoneExtra( ZoneEvent& ev );
void UpdateMbps( int64_t td );
int64_t ReadTimeline( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint32_t size, int64_t refTime, int32_t& childIdx );
void ReadTimelinePre063( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint64_t size, int64_t& refTime, int32_t& childIdx, int fileVer );
void ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx );