vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

C++ Autocomplete is slow on VSCode for mac development environment

Open linjiapro opened this issue 6 years ago • 13 comments

Auto complete is not automatically turned on for C++ on VSCode. I have a clean VSCode and this extension installed. I can force auto complete to happen by typing Ctrl+space.

My setting contains this:
"editor.quickSuggestions": true.

I googled it. It turns out that we had several related issues: https://github.com/microsoft/vscode-cpptools/issues/572 https://github.com/microsoft/vscode-cpptools/issues/574

I followed their way, and it turns out that this solves the problem: "editor.wordBasedSuggestions": true, "[c]": { "editor.wordBasedSuggestions": true }, "[cpp]": { "editor.wordBasedSuggestions": true }, "C_Cpp.autocomplete": "Disabled"

Now auto-complete is on, however, there is no color and type hint on the auto-complete, it is just plain English.

Those two previous issues linked here are from years ago. Is there a plan to solve the problem? Want to open this bug to track this.

linjiapro avatar Sep 23 '20 18:09 linjiapro

Update:

Actually, you can toggle autocomplete from settings for C++ now. Doing that fixes the issue.

linjiapro avatar Sep 23 '20 18:09 linjiapro

Reopening this. After I change autocomplete from settings for C++ to be default, the autocomplete takes more than multiple seconds to recommend something in large file, which is not very usable.

linjiapro avatar Sep 23 '20 20:09 linjiapro

Reopening this. After I change autocomplete from settings for C++ to be default, the autocomplete takes more than multiple seconds to recommend something in large file, which is not very usable.

Could you provide an estimate of how large the file is? How many lines? Also, is the file part of large sized project? It could be the extension is still tag parsing the files and dependencies in the project. If you enable the language server log it will show some logs on what the extension is processing.

michelleangela avatar Sep 23 '20 23:09 michelleangela

The file itself is a CPP file that is less than 200 lines. The total project is fairly large given it integrates third-party libraries, such as Libtorch, and OpenCV.

linjiapro avatar Sep 23 '20 23:09 linjiapro

I think there could be a bug, I enabled language server log, opened a file, and type something there, and here is the log:

sending 1 changes to server sending 1 changes to server sending 1 changes to server Checking for syntax errors: file:///Users/......... Queueing IntelliSense update for files in translation unit of: /Users/........

Why everytime I type something, 1 change is sending to server, could that be the cause of the lagging?

linjiapro avatar Sep 23 '20 23:09 linjiapro

The message "sending 1 changes to server" is expected, where any changes in the document is sent to the IntelliSense engine in order to evaluate the correctness of the code.

Did the project finished tag parsing the third party libraries? The log about this will show "tag parsing " and then end with "database safe to open".

michelleangela avatar Sep 23 '20 23:09 michelleangela

If you can send us instructions on how to reproduce the problem, we can investigate. Otherwise, unfortunately we don't have enough information to go on right now. Thank you!

bobbrow avatar Sep 23 '20 23:09 bobbrow

I did see "tag parsing file:", but it does not end with "database safe to open". Here is what it says: tag parsing file: /Users/linjia/.......cpp and there are also lots of logging like this: Error squiggle count: 0 Error squiggle count: 0 Error squiggle count: 0 Error squiggle count: 0

Steps to reproduce: Using the newest extension, open any large scale project, or can be a simple project but integrated with some 3rd party libraries, such as libtorch. Then the auto complete should be slow, but do let me know if not.

linjiapro avatar Sep 24 '20 00:09 linjiapro

Using the newest extension, open any large scale project, or can be a simple project but integrated with some 3rd party libraries, such as libtorch. Then the auto complete should be slow, but do let me know if not.

Sorry, that's not enough information to reproduce your problem. There are plenty of large scale projects integrated with 3rd party libraries that work just fine. We need specific steps that can be followed. Pretend you are teaching a new member of the team how to get started writing code for your project.

bobbrow avatar Sep 24 '20 00:09 bobbrow

I am experiencing the exact issue like this one: https://github.com/microsoft/vscode-cpptools/issues/5864

A more detailed step to reproduce: the OS is macOS on an Apple laptop.

Follow the minimal example step by step: https://pytorch.org/cppdocs/installing.html To properly reproduce, please get the downloaded libtorch folder under the project folder: ProjectRootFolder/ThirdParty/...

Open the project via the ProjectRootFolder, then you will be able to see the slowness. For issue 5864, I think Sean cannot reproduce because he did not put the libtorch folder under the project root so that the parser never scanned the libtorch folder.

On my end, I have disabled autocomplete, and retreat to wordBasedSuggestions as a workaround, the speed of wordBasedSuggestions is fast enough.

linjiapro avatar Sep 24 '20 00:09 linjiapro

Yeah, I'm not able to repro https://github.com/microsoft/vscode-cpptools/issues/5864. I have the libtorch folder under my workspace root. I don't know what the "ThirdParty" folder is. Maybe @Colengms or @michelleangela could try to repro it later on if they have time. Was there a specific file? I used the sample code that does #include <torch/torch.h>

sean-mcmanus avatar Sep 28 '20 21:09 sean-mcmanus

@sean-mcmanus, the "ThirdParty" is just a folder under project workspace root, which contains downloaded libraries, such as libtorch. I just reproduced this on a mac laptop. After pressing control+space, it takes more than 5 seconds to launch autocomplete.

linjiapro avatar Sep 28 '20 23:09 linjiapro

I just switched to Ubuntu for development. This problem disappears, and everything works like a charm. Confirmed that this is MAC only issue.

linjiapro avatar Oct 11 '20 23:10 linjiapro