microsoft / MIEngine

The Visual Studio MI Debug Engine ("MIEngine") provides an open-source Visual Studio Debugger extension that works with MI-enabled debuggers such as gdb and lldb.
MIT License
818 stars 218 forks source link

MIEngine: Disable individual info threads call for each thread created #1460

Open intel-rganesh opened 3 months ago

intel-rganesh commented 3 months ago

Changes to disable info thread for each created thread to expedite GPU debugging. GPUs are likely to have 1000s of threads and calling thread info for each thread created is very time consuming. We call SetThreadInfoFromResultValue from CollectThreadInfo when we get thread context.

Signed-off-by: intel-rganesh rakesh.ganesh@intel.com

gregg-miskelly commented 3 months ago

There are at least parts of this change that we don't want for CPU debugging -- with this change we will no longer raise up thread create events to the rest of the debugger when GDB raises a thread create, which would be a user-visible change at the least, and I am not sure if it would break other things that expect to get thread create events live.

For GPU debugging, I am also a bit worried this change isn't enough -- we will still wind up creating thread objects in the UI for all the GPU threads. Is that actually usable in either VS or VS Code? For example in the VS Code call stack window, or in VS in the parallel stacks, or threads window? I would have thought you would just want to show a small number (maybe just 1 virtual thread?) with some custom UI to select the thread.

intel-rganesh commented 1 month ago

For GPU debugging, the changes are to ensure we do not call thread-info for each thread. The thread created event is still called. Any NewThread should be added during GetThreadContext. I do see the Thread window and Parallel Stacks working fine (although it is slow).

image

Our use case is to show all the stopped GPU threads (similar to Threads in VS), lanes, be able to switch to different GPU threads/lanes and inspect variables.

The views function when we exit the kernel code and step in the CPU as well.

image