yse / easy_profiler

Lightweight profiler library for c++
MIT License
2.15k stars 184 forks source link

Thread affinity #65

Open minh0722 opened 7 years ago

minh0722 commented 7 years ago

Is there a way to know which core a thread is bounded to?

rationalcoder commented 7 years ago

Not in this version. That would take quite a bit more effort.

cas4ey commented 6 years ago

I have performed some investigation and realized that this is not as simple.

We could ask cpu id for each block when it starts, but this is not very reliable information because active cpu could change at any context switch. And additionally getting cpu id could be somewhat heavy operation (unconfirmed information).

Also it seems impossible to get cpu id for particular thread from another thread (when parsing context switch events in Windows build). Considering all the above, it seems that we should create a separate utility which would parse system tracing events (like a utility for gathering context switch events for Unix build).

So anyone who has more information on how to do this (for Windows, Linux, MacOS), please share your knowledge! :)