From d7541bbdba9db3b6f4b25f303271cf8ba61d8f15 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 21 May 2021 22:06:39 +0200 Subject: [PATCH 1/6] Allow disabling inline resolution on windows. Original commit a6b25497 by xavier : add TRACY_CALLSTACK_IGNORE_INLINES to tradeoff speed vs precision in win32 DecodeCallstackPtr() SymQueryInlineTrace() is too slow in some cases: 300000 queries backlog getting processed at ~70 per second is prohibitive. (without inlines resolution, it's more like ~20000 queries per second) --- client/TracyCallstack.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 4c87e6c7..28bbe763 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -292,7 +292,7 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr ) #ifdef TRACY_DBGHELP_LOCK DBGHELP_LOCK; #endif -#ifndef __CYGWIN__ +#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr ); DWORD ctx = 0; DWORD idx; @@ -335,7 +335,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) #ifdef TRACY_DBGHELP_LOCK DBGHELP_LOCK; #endif -#ifndef __CYGWIN__ +#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr ); if( inlineNum > MaxCbTrace - 1 ) inlineNum = MaxCbTrace - 1; DWORD ctx = 0; @@ -393,7 +393,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) } } -#ifndef __CYGWIN__ +#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES if( doInline ) { for( DWORD i=0; i Date: Fri, 21 May 2021 22:08:08 +0200 Subject: [PATCH 2/6] Update NEWS. --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index f68937ce..a10050b0 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,13 @@ be able to talk with each other. Network protocol breakages won't be listed here. +v0.x.x (xxxx-xx-xx) +------------------- + +- Added TRACY_NO_CALLSTACK_INLINES macro to disable inline functions + resolution in call stacks on Windows. + + v0.7.8 (2021-05-19) ------------------- From 621d1b03cd16849176d0d047107a9940fd6019cf Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 21 May 2021 22:27:19 +0200 Subject: [PATCH 3/6] Update manual. --- manual/tracy.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manual/tracy.tex b/manual/tracy.tex index 6fc358bb..afff202a 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -1531,6 +1531,10 @@ void DbgHelpUnlock() { ReleaseMutex(dbgHelpLock); } } \end{lstlisting} +\paragraph{Disabling resolution of inline frames} + +Inline frames retrieval on Windows can be multiple orders of magnitude slower than just performing basic symbol resolution. This is being manifested as profiler seemingly being stuck for a long time, having hundred thousands of query backlog entries queued, which are slowly trickling down. If your use case requires speed of operation rather than having call stacks with inline frames included, you may define the \texttt{TRACY\_NO\_CALLSTACK\_INLINES} macro, which will make the profiler stick to the basic but fast frame resolution mode. + \subsection{Lua support} To profile Lua code using Tracy, include the \texttt{tracy/TracyLua.hpp} header file in your Lua wrapper and execute \texttt{tracy::LuaRegister(lua\_State*)} function to add instrumentation support. From 1e6aedf9e6d85d5d59324ce404df22984978ebc0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 22 May 2021 01:05:06 +0200 Subject: [PATCH 4/6] Limit client query response rate. Original idea by xavier --- client/TracyProfiler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 9024c2d7..5aba68ca 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1687,10 +1687,12 @@ void Profiler::Worker() keepAlive = 0; } + int quota = 500; bool connActive = true; - while( m_sock->HasData() && connActive ) + while( quota-- && m_sock->HasData() ) { connActive = HandleServerQuery(); + if( !connActive ) break; } if( !connActive ) break; } From 6bb05c5b97dbe6d49a9991012c15267b263dc412 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 22 May 2021 01:12:33 +0200 Subject: [PATCH 5/6] Update NEWS. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index a10050b0..f9ac3f86 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ v0.x.x (xxxx-xx-xx) - Added TRACY_NO_CALLSTACK_INLINES macro to disable inline functions resolution in call stacks on Windows. +- Limited client query response rate. v0.7.8 (2021-05-19) From 68948712b47c01fabbb7d1d788345ac608ab5f43 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 22 May 2021 01:12:42 +0200 Subject: [PATCH 6/6] Don't sleep if queues are empty, but there's queries to handle. --- client/TracyProfiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 5aba68ca..bad57ef5 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1676,7 +1676,7 @@ void Profiler::Worker() keepAlive = 0; } - else + else if( !m_sock->HasData() ) { keepAlive++; std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );