vscode-cpptools
vscode-cpptools copied to clipboard
C/C++ intellisense extremely slow with large codebases (due to populating file name cache)
Environment
- OS and Version: Windows 11 (Windows_NT x64 Build 10.0.22631)
- VS Code Version: 1.86.2 (system setup)
- C/C++ Extension Version: v1.19.9
- If using SSH remote, specify OS of remote machine: Output of
uname -a
Linux hp-PowerEdge-T440 6.5.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 12 10:22:43 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Bug Summary and Steps to Reproduce
Bug Summary:
Large codebases like ns-3 take 2~5 min after opening and ~10s after that for whichever file you open to prepare syntax highlighting and IntelliSense.
Steps to reproduce:
- Git clone https://gitlab.com/nsnam/ns-3-dev.git
- Checkout any release tag. I am using v3.40.
git checkout tags/ns-3.40
- Open the folder in VSCode.
- Open any file.
- Watch the syntax highlighting and IntelliSense take ages to load. (Build all CMake targets first if it fails)
- The problem is more pronounced when using third-party modules. (More code in the contrib directory)
Expected behaviour:
- Speed up the process, please. If VSCode needs more processes, it can have them.
- If direct speedup is not possible, VSCode should at least prepare IntelliSense for the files open in the current workspace in the background after the working file is ready.
Configuration and Logs
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/build/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
Other Extensions
No response
Additional context
htop
shows only a single CPU core at 100% when a new file is opened. All the others are idle. (<10%)
IMHO, it doesn't seem like performance is this extension's priority, because there are a ton of issues titled similarly to this. I also wish it could be faster, but I ended up resorting to the clangd
extension instead, which somehow leaves cpptools
in the dust when parsing large codebases. In every other aspect though, this extension is nicer.
@kitswas I just tried cloning your project and configured with CMake on Windows. Is there a particular file that you are having problems with? I wasn't able to repro a performance problem with the few files I tried.
https://github.com/microsoft/vscode-cpptools/assets/12818240/ea608e73-b482-4182-86de-f5bebc0b4800
This is on a local machine though. You seem to indicate that you're connecting to a remote machine? It's not WSL, is it? Can you share more details about your remote setup? Our extension doesn't manage communication back and forth between machines, but it's possible that something is configured sub-optimally that is resulting in delays. It looked like there were only about 3300 source/header files in this repo and our extension can normally handle a project of that size ok.
@trustytrojan We feel your pain and have been experimenting with alternate approaches to deal with the performance issues you are referring to. These efforts have not yielded the wholesale improvements we're looking for yet, but we have been scaling up the investment here and hope to announce more improvements in the future. Our most recent improvements were released in version 1.19 (progressive IntelliSense updates, and a rewrite of the symbol search feature).
@kitswas Also, if you can set C_Cpp.loggingLeve to "Debug", the logging might indicate what is taking so long to process. Also, with 1.20.0 (pre-release), you could attach a debugger and provide the call stacks (for the thread that appears to be using the CPU).
@bobbrow
I just tried cloning your project and configured with CMake on Windows. Is there a particular file that you are having problems with? I wasn't able to repro a performance problem with the few files I tried.
ns3 can only run/compile in a Linux environment. To use ns-3 on Windows, you need the Windows Subsystem for Linux (WSL) or the Msys2/MinGW64 toolchain.
Did you wait for all the symbols to get highlighted and the popup-on-hover to start working?
The C++ and the 🔥(IntelliSense) spinners sometimes stop early.
This is on a local machine though. You seem to indicate that you're connecting to a remote machine? It's not WSL, is it? Can you share more details about your remote setup? Our extension doesn't manage communication back and forth between machines, but it's possible that something is configured sub-optimally that is resulting in delays.
I am connecting to an Ubuntu 22.04 machine via ssh over LAN.
It looked like there were only about 3300 source/header files in this repo and our extension can normally handle a project of that size ok.
That's the base ns3 repo with no third-party modules. My current repo has 4177 C++ source and header files.
Let's see if I can get you something closer to what I am working with now.
@sean-mcmanus Here's the log (level Debug) after switching to a different file.
It contains the lines:
Populating file name cache...
Done populating filename cache. Elapsed time: 15585 ms
...
Update IntelliSense time (sec): 9.954
That's a total of 25 seconds for Intellisense to become fully functional.
@kitswas Yes, it's stuck populating the file name cache. This is a performance issue we've are aware of and I believe another member on our team is actively working on fixing that (unless I'm mistaken). One prior bug is https://github.com/microsoft/vscode-cpptools/issues/11954 , although that doesn't mention IntelliSense being blocked, so we can use this issue to track the IntelliSense case.
Well, that's for the 15 sec, but the 10 sec updating time might be improvied via https://github.com/microsoft/vscode-cpptools/issues/3628 or https://github.com/microsoft/vscode-cpptools/issues/5362 or other performance work that is in progress.
As @sean-mcmanus mentions, the filename cache is an area we're working to improve. Soon, this will only delay IntelliSense the first time you open a workspace, not every time you open the same workspace. For me with all files local to the machine, this doesn't take long.
Done populating filename cache. Elapsed time: 139 ms
Did you wait for all the symbols to get highlighted and the popup-on-hover to start working?
I didn't have to wait long. I'm not sure why your machine takes 10 seconds and mine takes 1 second.
Update IntelliSense time (sec): 0.879
We have heard of issues with remote work taking longer, but it's hard to know. Are all of your files/compilers/headers local to the remote machine, or are there any network drives involved?
All of my remotes are dead right now, but I was able to spin up a Codespace for this repo and saw some numbers closer to yours. filename cache took 3~5 seconds to populate. IntelliSense took 3~8 seconds depending on the source file.
ns3 can only run/compile in a Linux environment. To use ns-3 on Windows, you need the Windows Subsystem for Linux (WSL) or the Msys2/MinGW64 toolchain.
I didn't try to build on Windows. I just configured with CMake to get IntelliSense configurations and tested the IntelliSense. The Codespace is linux.
That's the base ns3 repo with no third-party modules. My current repo has 4177 C++ source and header files. Let's see if I can get you something closer to what I am working with now.
I was looking for instructions, but didn't see anything about submodules or anything. If you have more info on how to set this up, I can add the extra files and see if it makes a difference. Also, the file in your log wasn't in the default repo (contrib is empty for me), so I couldn't test with that file.
Thank you for your patience.
We have heard of issues with remote work taking longer, but it's hard to know. Are all of your files/compilers/headers local to the remote machine, or are there any network drives involved?
All my files are on a drive local to the remote machine (Dell PowerEdge t440).
I was looking for instructions, but didn't see anything about submodules or anything. If you have more info on how to set this up, I can add the extra files and see if it makes a difference. Also, the file in your log wasn't in the default repo (contrib is empty for me), so I couldn't test with that file.
Try this repo. https://gitlab.com/kitswas/coexistence-wigig-5gnr/-/tree/master/scratch?ref_type=heads#3rd-party-modules Please follow the instructions to set up contrib. The ns-3 project does not use git submodules yet.
same here and any source file editing make c-language spinning(bottom status bar show me this), and block the formatting util the unspinning
Same issue.
Vscode remote mode(client on mac or windows, server on a pertty high performance linux server):
The IntelliSense is rather not soomth when I open a cpp file.
Whenever I open a C++ file(cpp or h), the 'IntelliSense scan' and 'parsing workspace' process will be launched.
It will take about a minute, and I can not use the functions such as 'Go to definition' or 'Go to implemention' which are dependent on IntelliSense funtion until the process is finished.
And If I go to a new cpp file, the scan and parsing process need run again before I can 'Go to definition'...
Vscode local mode:
- run on mac: IntelliSense Performance issue is sill there.
- run on windows: IntelliSense Performance is far better than on mac(local mode) and on linux(Remote mode).
@kitswas @trustytrojan @XuPengfei-1020 We've made improvements with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.22.0 . Let us know if it's still an issue for you with that version.