Monitor send queue size.

This commit is contained in:
Bartosz Taudul 2022-07-03 14:52:18 +02:00
parent 3c49dea10c
commit edad2d7e35
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 42 additions and 1 deletions

View File

@ -805,6 +805,13 @@ private:
bool groupTopDown = true; bool groupTopDown = true;
} m_sampleParents; } m_sampleParents;
struct
{
bool enabled = false;
bool monitor = false;
int64_t time;
} m_sendQueueWarning;
std::vector<std::pair<int, int>> m_cpuUsageBuf; std::vector<std::pair<int, int>> m_cpuUsageBuf;
}; };

View File

@ -10,12 +10,17 @@
namespace tracy namespace tracy
{ {
constexpr size_t SendQueueEnableThreshold = 1000000;
constexpr size_t SendQueueDisableThreshold = 500000;
constexpr int64_t SendQueueTimespanMs = 10000; // 10 s
bool View::DrawConnection() bool View::DrawConnection()
{ {
const auto scale = GetScale(); const auto scale = GetScale();
const auto ty = ImGui::GetTextLineHeight(); const auto ty = ImGui::GetTextLineHeight();
const auto cs = ty * 0.9f; const auto cs = ty * 0.9f;
const auto isConnected = m_worker.IsConnected(); const auto isConnected = m_worker.IsConnected();
size_t sendQueue;
{ {
std::shared_lock<std::shared_mutex> lock( m_worker.GetMbpsDataLock() ); std::shared_lock<std::shared_mutex> lock( m_worker.GetMbpsDataLock() );
@ -42,7 +47,36 @@ bool View::DrawConnection()
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text( "%6.2f Mbps", mbps / m_worker.GetCompRatio() ); ImGui::Text( "%6.2f Mbps", mbps / m_worker.GetCompRatio() );
TextFocused( "Data transferred:", MemSizeToString( m_worker.GetDataTransferred() ) ); TextFocused( "Data transferred:", MemSizeToString( m_worker.GetDataTransferred() ) );
TextFocused( "Query backlog:", RealToString( m_worker.GetSendQueueSize() ) ); sendQueue = m_worker.GetSendQueueSize();
TextFocused( "Query backlog:", RealToString( sendQueue ) );
}
if( !m_sendQueueWarning.enabled )
{
if( !m_sendQueueWarning.monitor )
{
if( sendQueue > SendQueueEnableThreshold )
{
m_sendQueueWarning.monitor = true;
m_sendQueueWarning.time = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count();
}
}
else
{
if( sendQueue < SendQueueDisableThreshold )
{
m_sendQueueWarning.monitor = false;
}
else
{
const auto t = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count();
if( t - m_sendQueueWarning.time > SendQueueTimespanMs )
{
m_sendQueueWarning.enabled = true;
m_sendQueueWarning.monitor = false;
}
}
}
} }
const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin(); const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin();