Improving C++ Intellisense Performance with PCH

Improving C++ Intellisense Performance with PCH

  • Comments 23

Thank you to everyone who has submitted feedback on the Visual Studio Release Candidate. We have received feedback that C++ Intellisense performance is slower. One way to improve this is to enable Pre-Compiled Headers usage for Intellisense parser. Andy Rich has written a detailed post on intellisense PCH usage that gives some additional details and explains how to optimize your intellisense engine with PCH. Here are a few of the benefits of using PCH:

·         Improves Intellisense parser performance in the IDE

·         iPCH is on by default as long as your project is using PCH

 

Thank you,

 

Kelly Evans

Visual C++ Team

  • @JK:

    @Mike The Pike:

    @nbelyh:

    Ok, after some digging into this bug, the current behavior is more like "By Design" than "Bug".  

    Here's why:

    The reason why build compiler succeeded when intellisense failed on #include "stdafx.h" is because you were still using PCH for the project and the new file inherited that property.  So, when build compiler sees #include "stdafx.h" it automatically loads the .pch file without doing any look-up for the actual header file.  Once PCH is loaded, all symbols resolve and build succeeds.  If you turn-off PCH for the project and do a Re-Build, you will see a compiler error in the output that's same as the Intellisense squiggle error.

    When you add #include "stdafx.h" to any file the compiler or intellisense parser will follow the lookup heuristic of searching current directory and then searching INCLUDE path.  In both cases stdafx.h will not found because it's in the $(ProjectDir) folder and your source is in a different folder. One easy way fix this in your project would be to add $(ProjectDir) to your Include Directories under "VC++ Directories" property.

    Hopefully, this makes sense.

    Thanks,

    Ulzii Luvsanbat

    Windows C++ Team

  • Our codebase is large, we have 39907 files in more then 275 projects (C++, C++/CLI, C#). Loading everything in a solution as always been difficult because IntelliSense took to much time to generate. It took 3 hours for IntelliSense to generate in Visual Studio 2008.

    Even if IntelliSense was done generating, it wasn't working in a predictable way. In fact, searching a symbol or reference could make Visual Studio hang for minutes (or even crash) - Go to Definition worked sometimes - Corruption with the IntelliSense file (.ncb). As well as the time it takes to load a solution (minutes!).

    The only reason we are using Visual Studio is for debugging and compiling (with custom tools that calls your compiler). Editing is done in SlickEdit. We aren't loading all the code in the IDE but we still get all the mentionned featured described above with the TagFiles. Which are some kind of IntelliSense but pregenerated.

    I have also tried 2010 Beta 1 and Beta 2 and IntelliSense was worse then 2008 in terms of performance and realiability.

    Now RC arrived, so I will attempt to benchmark and share the results.

    First, I changed computer since I last did my tests. I have a DELL Optiplex 960, Core 2 Duo, with RAID disks. Before I had a Pentium 3.0 Ghz with sata drive. So I will benchmark again with 2008 SP1 and 2010 RC.

    Visual Studio 2008 - Took 40 minutes...(from 3 hours) but like I said above IntelliSense is not performing the way we want.

    Visual Studio 2010 RC

    -Convertion of 2008 .sln was fast and IDE was responsive during that time (Detected 380 projects)

    -Then "Loading of solution..."

    -"Preparing Solution..." Took about 4 minutes with conversion.

    -"Parsing files in solution..." (34078 files) (14:07 to 14:13)

    -"Scanning includes for additional files..." (119547 files) (14:13 to 14:18)

    -"Parsing included files..." (5366 files) (14:18 to 14:19)

    -Missed some steps...

    -"Initializing...(1 of 250)" (14:19 to 14:23)

    -"Parsing files in solution (... of 5784)" (14:23 to 14:23)

    -"Scanning includes for additional files... (... of 256800)" (14:23 - 14:32) (Here the total of file went from about 256800 to about 524007)

    -Missed a step...

    -Now multiple "Scanning #includes for additional files... " steps from 200 to 500 files each.

    -"Scanning includes for additional files... (... of X)" (Again the total went up to about 532366).

    -Again multiple "Scanning #include..." (14:36 to 14:38)

    -Loop between "Scanning includes for additional files..." and "Scanning #includes for additional files..." (14:38 to 14:48)

    -Up to here we get 41 minutes.

    -"Please wait while IntelliSense and browsing information are updated." (14:48 to ?)

    -Now again multiple "Scanning ..."...when will this end? Could a progress bar be added?

    While waiting I decided to do a Go To Definition, a dialog said to wait for IntelliSense to finish. This is good. A button lets you Cancel. It is not clear if it will cancel IntelliSense generation or close the dialog. I clicked and it only closed the dialog. This should be corrected.

    Now it is 16:30 and the "Please wait while IntelliSense..." is still written in status bar. I will let it go for the night and see tomorrow. I am taking screenshots every minute so I will be able to tell when IntelliSense was done generating.

    We want to let our programmers open the files they want without opening everything. Copying code locally is too long. A programmer may want to just open 2 projects but still be able to "Go to Defintion" to a source that is not in his solution. The best would be to generate the .ncb file, then sharing it. Therefore, they could work on a file and still be able to use IntelliSense. Is this scenario possible? Is there any way I can access the IntelliSense .sdf file and retrieve IntelliSense information? We don't care about the local changes, we wan't a static IntelliSense .ncb generated once per day that can be shared. If we can have the local changes its even better but not essential.

    Also, our programmers need to work on different versions of the code. We can't afford to wait for IntelliSense to be available each time they open a solution. Do we still have to wait until the next Visual Studio version to get a better IntelliSense? We have been waiting since 2002 and at each release we have been disappointed. But I must say that a lot of progress have been done with VS2010 particularly, with precision and responsiveness. I will attempt tomorrow to test more througly IntelliSense and give you feedback.

    In the code editor, I see some red waves under #include directives. It would be great if a report could be generated so we could fix those issues and therefore get a better performing IntelliSense. I can't imagine myself going through 40000 files to make sure we no longer have any red waves. Is this possible?

    Let me know how we can work this out.

    If you need more feedback don't hesitate.

    Cédric

  • (...)

    The screensaver was on and I think it prevented the taskbar from updating correctly.

    (17:10)

    "Please wait IntelliSense and browsing information are updated." was still showing.

    *** Taskbar did not update correctly. I suspect IntelliSense was done generating here. But when? ***

    (22:10 to 22:30)

    It says "Scanning #includes for additional files...(X of 555219)". I hope IntelliSense was already done generating and this is just an update that IntelliSense does at specific intervals, am I right?

    Then "Ready" until 00:07 and a new message I never seen before, "Checking for out of date files...(X of 34078)".

    (00:09 to 00:27)

    It says "Scanning #includes for additional files...(X of 555219).

    *** Taskbar did not update correctly. No updates, until 03:41 which says "Ready". ***

    (08:13 to 8:35)

    "Scanning #includes for additional files...(X of 555244)

    Currently message is "Ready".

    In order to know exactly how much time it tooked I will have to restart it again and without the screensaver.

    I will also attempt to copy the .sdf on another computer and see how it reacts.

    I will post results later.

    Here's feedback on using IntelliSense:

    -Red waves appear sometimes under #include directives, it says "Error: cannot open source file "X.h". The file exist, because if I do CTRL-SHIFT-G (Open document

    <X.h>) finds it. What's wrong?

    -It occurs that I get the popup "Visual Studio is busy" while doing a GoToDefinition. Seems to occur more often when definition is in same file.

    -Every IntelliSense operation usually take 5 to 15 seconds to complete but I never had a crash though I could wait seconds before IDE came back alive. This is a huge progress towards previous Visual Studio release.

    -Memory footprint is much more in control then in previous releases.

    More suggestions:

    -There should be a diagnostic report that we could read that gives recommendation on how to better use IntelliSense (some kind of FxCop). The report could also be sent to you and therefore be able to see what was done, how much time took steps, how many files, etc.

    -We have files that contains blocks of C++. In order to get syntax coloring we always set the "Editing Experience to Visual C++". When we compile a tool then reads these files and generates a cpp file. IntelliSense is working quite well in this files which is good. The problem is that we get a lot of red waves in this files.

    Is it possible for IntelliSense to be usable in this files but ignore the red waves?

    -The small icon with 2 yellow + that appears left to the line number in status bar should be more appearant. Could it be shown in tab between filename and X?

    -Can we have an option to prevent IntelliSense from updating. Because when it start updating we can't use IntelliSense (dialog "Please wait while IntelliSense and browsing information are updated." and IDE is unresponsive. Could it at least rely on old .sdf and when done swap with new .sdf?

    Cédric

  • (...)

    1) I have generated again IntelliSense and it took 46 minutes. This is very good. This time the message "Please wait IntelliSense and browsing information are updated." did not stay stuck in the status bar. I can't explain the difference between my last test. I will attempt a third generation and see if I get the same generation time.

    2) I have attempted to share the .sdf and it works. This is incredible and something we always wanted. Now, it could be possible to pregenerate the sdf and share it. I will push the tests further next week and come back on this.

    Sorry for the long posts but you asked for feedback ;)

    Cédric

  • @cguillemette  thanks for sending us a lot of feedback. As regards as some of your concerns

    We have done some performance work in RTM in area regarding the parsing of files when the solution Intellisense database (sdf) gets created. You may not see this issue in the Final Release of Dev10.

    For Intellisense improvement you should enable pre compiled headers for Intellisense. You can look at the following post how to use pch in the project

    http://blogs.msdn.com/vcblog/archive/2010/01/26/precompiled-header-files-in-visual-studio-2010.aspx

    For the red squiggles you can look at all the errors in the project in the error list. You can bring it up by going to

    View -> Error List

    You can disable red lines or squiggles at the solution level not at the project or file level. You can disable squiggles in the solution by going to

    Tools->Options->Text Editor->C/C++->Advanced->Under Intellisense -> Disable Squiggles to true

    Can you let us know how much does it takes the IDE to come back and be responsive after you invoke the GoToDefinition operation in the file.

    Some of your questions are answered as

    Every IntelliSense operation usually take 5 to 15 seconds to complete but I never had a crash though I could wait seconds before IDE came back alive.

    We would like to know which Intellisense operation is taking 5-15 seconds.. We presume it might be Gotodefinition here as QuickInfo and other Intellisense operations should not take that long.

    There should be a diagnostic report that we could read that gives recommendation on how to better use IntelliSense (some kind of FxCop). The report could also be sent to you and therefore be able to see what was done, how much time took steps, how many files

    Thanks for your suggestion. It’s a nice one. We have noted it and will take into consideration.

    We have files that contains blocks of C++. In order to get syntax coloring we always set the "Editing Experience to Visual C++". When we compile a tool then reads these files and generates a cpp file. IntelliSense is working quite well in this files which is good. The problem is that we get a lot of red waves in this files.

    Are these files *.cpp or *.c files . You should not be getting red squiggles in these files if they are compilable c++ files.

    Is it possible for IntelliSense to be usable in this files but ignore the red waves?

    The red squiggles appear in file when Intellisense finds some issues with the code constructs in the file. Like when it cannot a definition for a class whose object is being used in file. Intellisense is supposed to work at places in valid c++ code even if the file has any errors in it.

    -Can we have an option to prevent IntelliSense from updating. Because when it start updating we can't use IntelliSense (dialog "Please wait while IntelliSense and browsing information are updated." and IDE is unresponsive. Could it at least rely on old .sdf and when done swap with new .sdf?

    You can disable the updates to database by setting “Disable Database Auto Updates” to true

    Tools->Options->Text Editor->C/C++->Advanced-> Under Browsing/Navigation

    Set Disable Database Auto Updates to true.

    I have attempted to share the .sdf and it works. This is incredible and something we always wanted. Now, it could be possible to pregenerate the sdf and share it

    Sharing sdf file is not a supported scenario in Visual Studio 2010. The sdf file for a solution gets generated first time it is opened. On the subsequent openings of the same solution it just gets updated with any new changes in the projects.

    We want to let our programmers open the files they want without opening everything. Copying code locally is too long. A programmer may want to just open 2 projects but still be able to "Go to Defintion" to a source that is not in his solution. The best would be to generate the .ncb file, then sharing it. Therefore, they could work on a file and still be able to use IntelliSense. Is this scenario possible?

    This scenario is not supported.

    Is there any way I can access the IntelliSense .sdf file and retrieve IntelliSense information?

    Sdf is database file. You can access it and access the information in it. But I don’t know how you can make the best out of it.

    Also, our programmers need to work on different versions of the code. We can't afford to wait for IntelliSense to be available each time they open a solution. Do we still have to wait until the next Visual Studio version to get a better IntelliSense?

    It takes time in creating the Intellisense database first time when solution is loaded. It takes less amount of time on subsequent openings of the solution. So ideally your developers should not face the problem you are talking here..If they are facing this issue than let us know about it.

    Regards

    Rashid Sarwar

    Windows C++ team

  • Is there a way to reduce the output during builds? I'm getting a ton of spam when I build with 2010 RC-- making it sometimes hard to find the actual errors.

    Pages of and pages of stuff like this..

    Task "Message" skipped, due to false condition; ('$(SkipCopyBuildProduct)'!='true') was evaluated as ('true'!='true').

    3>Task "Copy" skipped, due to false condition; ('@(AddModules)' != '') was evaluated as ('' != '').

    3>Task "Copy" skipped, due to false condition; ('$(_SGenDllCreated)'=='true') was evaluated as ('false'=='true').

    3>Task "Copy" skipped, due to false condition; ('$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true') was evaluated as ('false'=='true' and '' != 'true' and 'true'=='true').

    3>Task "Copy" skipped, due to false condition; ('$(_DocumentationFileProduced)'=='true') was evaluated as ('false'=='true').

    3>Task "Copy" skipped, due to false condition; ('@(IntermediateSatelliteAssembliesWithTargetPath)' != '') was evaluated as ('' != '').

    3>Task "Copy" skipped, due to false cond

  • shaz > options, projects and solutions, build and run, "MSBuild project build output verbosity"

  • @Axel:

    The bug you have reported about VS IDE maximizing on its own, has been fixed for VS2010 RTM.  You will not experience that behavior again.  Thank you for sharing your feedback in time.

    Thanks,

    Ulzii Luvsanbat

    Windows C++ Team

Page 2 of 2 (23 items) 12