microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

show symbols slowly in vscode #1686

Closed chongchai closed 5 years ago

chongchai commented 6 years ago

Env

My Case for Reproduce

I open a large project like linux kernel project then try to navigate code.

So can the last two choices be quicker? Especially for searching whole workspace symbols.

sean-mcmanus commented 6 years ago

Find Symbols in File is fast for me (I've tried the linux kernel too, are you opening a particular file?). Can you help provide more repro details as to when it's slow and for how many seconds? Can you make sure that you aren't doing another expensive operation before the Find Symbols in File, because the operation could be blocked by the previous operation (most likely, it would be blocked by a previous Find Symbols in Workspace operation).

Are you seeing Find Symbols in Workspace being slow after the 1st time it's run and results are returned? How many seconds approximately? I'm seeing up to 3-4 seconds or so. Is that what you're seeing? There might be a way for us to speed that up.

Find Symbols in Workspace is known to be slow the 1st time it's run as an in-memory cache of symbols over the entire workspace is built from the database, which can take a long time. The easiest way to "fix" this might be to just queue the caching at activation or after idling occurs (it'll run in the a separate thread so hopefully the processing would go unnoticed). It's possible there could be other optimizations, but we haven't investigated this yet.

chongchai commented 6 years ago

@sean-mcmanus My repo is https://github.com/torvalds/linux.git.

I think there are two ways to "Find Symbols in File". The one is to use the command "C_Cpp.Navigate" (or global scope in the status bar) which is fast enough. The other one is to use the sys command "workbench.action.gotoSymbol" ( pressing "Ctrl+Shift+O") which is much slower.

"Find Symbols in Workspace" only can be invoked by "workbench.action.showAllSymbols" (pressing "Ctrl+T") which is also slow.

Reproduce Step

  1. git clone https://github.com/torvalds/linux.git in windows 7.
  2. use vscode 1.20.0 to open the project. The vscode just installs the c/c++ 0.14.6 extension.
  3. open the file kernel\cgroup\cgroup.c
  4. press "Ctrl+T" to Find Symbols in Workspace. It consumes about 4 seconds to show results list. Then I input to search symbol "cgroup" . But after 20 seconds, it still doesn't return results.
  5. press "Ctrl+Shift+O" to Find Symbos in File. It doesn't return results after 20 seconds.
  6. press "Ctrl+Shift+P" and select "C_Cpp.Navigate" to Find Symbos in File. It return results in 1 seconds.
sean-mcmanus commented 6 years ago

Yeah, you're doing Find Symbols in File right after Find Symbols in Workspace -- both operations share the same thread queue. If you do Find Symbols in File first it should be fast, right? Also, can you verify that it's fast the 2nd time?

sean-mcmanus commented 6 years ago

What result list do you get after 4 seconds? I assume nothing, right? We just show the # (unless you have some identifier at the cursor position, in which case that is auto-added).

chongchai commented 6 years ago

Yeah, you're doing Find Symbols in File right after Find Symbols in Workspace -- both operations share the same thread queue. If you do Find Symbols in File first it should be fast, right? Also, can you verify that it's fast the 2nd time?

I did these tests:

  1. I restart vscode and open the kernel\cgroup\cgroup.c .
  2. Press "Ctrl+Shift+O" to Find Symbols in File. It doesn't return after 20 seconds.
  3. Wait several seconds and press again, It shows results quickly.
  4. Wait several seconds and press again, It shows results after about 10 seconds.

From your description, I guess the first time to Find Symbols in File is slow and second time is fast? But after my several tests, it can't be a stable case.


What result list do you get after 4 seconds? I assume nothing, right? We just show the # (unless you have some identifier at the cursor position, in which case that is auto-added).

Actually the result list is not empty after 4 seconds (in this case my cursor doesn't stay at any identifier which mean it finds all the symbols in the workspace to return). Then I input cgroup after the #, it doesn't return after 20 seconds.


Is anything can be done to improve these user experience? I think "find symbols in workspace and file" is an important function for user to read source code.

chongchai commented 6 years ago

I update my c/c++ entension to v0.15.0 and find something changed.

Find symbols in File ("Ctrl+Shift+O") is fast now.

Find symbols in Workspace("Ctrl+T") is still slow (about 10 seconds).

sean-mcmanus commented 6 years ago

Also, if there's a red flame in the bottom right immediately after opening a file, it could block the Find Symbol operation until the flame disappears. I'm seeing Find Symbols in Workspace take a very long time >10 seconds the 1st time it's used, but afterwards it only takes 2 seconds (with kernel\cgroup\cgroup.c open with a symbol like cgroup_bpf_put. Are you able to get the 2 second repeated time? What text do you have after # that is slow? Did you want us to improve the 1st launch performance (cache building) or the repeated time? Not many users have complained about this, compared to other problems (such as intellisense configuration), so it hasn't been a priority to improve.

chujinjin101 commented 6 years ago

I also have the performance problem,can you tell me where is the code entry of searching symbols in workspace?

sean-mcmanus commented 6 years ago

@zjuchujinjin You mean the source code? It's part of the closed source language server process.

chongchai commented 6 years ago

@sean-mcmanus I also test to search symbol cgroup_bpf_put in kernel\cgroup\cgroup.c. I open the file and wait the red flame to disappear. Then I Find Symbols in Workspace. First time it takes a very long time. But the second time, third time ... it still takes a long time about 10 seconds (not 2 seconds like your case).

Also I find if I Find Symbols in File without Find Symbols in Workspace, the time is fast. But after I test to Find Symbols in Workspace, Find Symbols in File will be slower (about 5-6 second) compared to the first time search. I realized the two actions are shared same thread queue from what you said before. But I think Find Symbols in File shouldn't be slower after I Find Symbols in Workspace, since I have waited a long time after Find Symbols in Workspace.

sean-mcmanus commented 6 years ago

Hmm, that's odd. I'm not reproing the behavior you're describing. Maybe I need to test on a slower machine? Is there a database icon in the bottom right?

chongchai commented 6 years ago

The database icon will disappear soon after I open the file. So when I do these tests, the red flame and database are both not in the bottom right.

My env is vscode 1.21.1 and C/C++ 0.16.0-insiders, windows 7 with 16GB RAM and Intel Xeon CPU E5-2680.

mgaudet commented 6 years ago

I'm seeing a similar issue on OS/X. This is the Spidermonkey javascript engine, using this c_cpp_properties.json.

One general comment is that I'm being trained out of symbol search, simply because the full text search is so much faster.

sean-mcmanus commented 6 years ago

@mgaudet I use full text search instead of symbol search as well.

@chongchai I suspect the difference in performance is that your Linux directory has been build, causing more symbols to be generated, although I don't know why the Find Symbols in File would become slower (I'm not reproing that).

michelleangela commented 5 years ago

Closing this issue as the last response is more than a year old.

Update to the latest version of the C/C++ extension and see if issue still persists. Please re-open the issue and reply with additional information that can help us investigate the issue.