Check if external threads are local.

For some unknown reason, local threads may be attributed to an external
process (at least when profiling on Windows). This causes some problems,
for example the CPU usage graph may show that CPU is pegged by some other
program, when it reality it is the profiled program that uses the CPU time.

Workaround by checking first, if the thread id is known to be local by the
profiler, i.e. if there were user-generated events originating from it.

This still leaves other things, such as the CPU data list, being wrong,
but the CPU data is meant to show raw TID -> PID mapping. If the source
data is wrong, there's not much to fix here.
This commit is contained in:
Bartosz Taudul 2023-04-30 13:55:49 +02:00
parent 0f0ac2d6c5
commit 2e9d8f8215
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -7091,7 +7091,8 @@ void Worker::ReconstructContextSwitchUsage()
{ {
const auto ct = !cpus[i].startDone ? cpus[i].it->Start() : cpus[i].it->End(); const auto ct = !cpus[i].startDone ? cpus[i].it->Start() : cpus[i].it->End();
if( nextTime != ct ) break; if( nextTime != ct ) break;
const auto isOwn = GetPidFromTid( DecompressThreadExternal( cpus[i].it->Thread() ) ) == m_pid; const auto tid = DecompressThreadExternal( cpus[i].it->Thread() );
const auto isOwn = IsThreadLocal( tid ) || GetPidFromTid( tid ) == m_pid;
if( !cpus[i].startDone ) if( !cpus[i].startDone )
{ {
if( isOwn ) if( isOwn )