vscode: Debugging in VSCode is significantly slower than using command line #4514
- VS Code Version: Version: 1.58.2 (user setup) Commit: c3f126316369cd610563c75b1b1725e0679adfb3 Date: 2021-07-14T22:10:15.214Z Electron: 12.0.13 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.18363
- OS Version:
Steps to Reproduce:
- Debug a C++program with more than 10 threads. See also in https://github.com/microsoft/vscode-cpptools/issues/4514
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 52
- Comments: 17 (3 by maintainers)
Here is what happens when a break point is hit and why it takes so long. The break point is hit:
Information about all(!) threads is requested:
While GDB executes the request above, it reports availability of new threads (158 in my case):
vscode starts to request info about each reported thread. Even though information about all threads has been requested earlier:
Information about all 158 threads has been requested. After 11 seconds GDB returns response to request
1024-thread-info
and starts to slowly return responses for individual thread info requests:After 151 (!) seconds GDB responds to the last thread info request and vscode is almost ready to inform a user about the break point:
Conclusion: it is not needed to request individual thread info since all thread info is requested anyway and such combined request is executed much much faster compared to many individual requests.
As reported above, the “Native Debug” extension does not suffer from this problem which is evidence, that VS Code is not the problem. I suggest that you file issues against the debug extensions you are using.
There’s the same issue when the debugger has to load many dlls, even if the application is single threaded. Command line gdb is fast, but the same from vscode is slow. The debug console is filled with “=library-unloaded,id=…” messages.
Please re-open this issue. The problem exists when using VS Code with the C/C++ extension (both from Microsoft and both are great). The suggestion to use the Native Debug extension is not a good option, since it is very limited compared to the excellent debugger in the MS C/C++ extension. The lack of features may be the reason why the Native Debug extension works faster. Here https://github.com/microsoft/vscode/issues/132025#issuecomment-1132866384 I provided the exact reason of the slowdown. I can’t say which party (VS Code or the C/C++ extension) requests unneeded information from gdb when the first breakpoint is hit. It is needed to investigate this by looking at the source code before closing the issue. Thanks.
For me, https://github.com/microsoft/vscode/issues/132025#issuecomment-909792995, https://github.com/microsoft/vscode/issues/132025#issuecomment-909792995, and https://github.com/microsoft/vscode/issues/132025#issuecomment-1132866384 point to the right direction where to tackle that issue actually.
Please don’t close that issue prematurely. In my opinion, the Native Debug extension is not comparable.