Hi, my name is Jim Springfield, and I’m an architect on the Visual C++ team. I recently spent two months working on some core improvements to how VC deals with Intellisense as well as overall UI responsiveness.
We observed a strong correlation between the severity of these performance issues and the size of the projects and solutions exhibiting these problems. As a result, we worked closely with some large ISV customers who were reporting problems with our IDE. These customers typically had solutions with over a hundred projects comprising thousands of files. While I can’t identify them by full name, I want to give a shout out to them and thank them for their time and effort. So, thank you to Bob, Don, Dick, Rainer, Kelly, and Mike, you know who you are.
While I was working on these changes as a Quick Fix Engineering patch (or, “QFE”) for Visual Studio 2005, I was also tracking the changes for Visual Studio 2008 “Orcas,” and I am happy to report that all of these changes will be available in VS2008 as well as available in a publicly available QFE (also called a General Distribution Release, or “GDR”) for VS2005.
The GDR can be downloaded from the link below. You will be prompted to login with a Windows Live ID or Passport first and then taken to the actual download location. http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=9436
I wish I could say everything in these areas is fixed as a part of our efforts. However, the reality is that there were some issues that needed more substantial work and which was impossible to accomplish in this time frame. We are already working on the next release beyond VS2008 and addressing these issues will be one of our top priorities. We are fundamentally changing how we approach Intellisense and we are designing with the largest solutions in mind. We will be blogging about the direction this work is going, so watch this space for additional information on these efforts as the work we are doing here is quite interesting.
To give you a feel for the scope of the changes we made to address these issues in VS2005 and VS2008, this work touched 46 source files across three DLL’s. Overall, 4664 lines of code were changed or added. I would like to take this opportunity to give you a bit of insight into the nature of problems we identified and the solutions we implemented.
The .NCB file (an in-memory Intellisense data) was protected with a simple critical section to prevent simultaneous access from multiple threads. However, often there were multiple threads that just wanted to read information the NCB, not modify it, so we replaced the NCB critical section with a multi-reader/single-writer lock. This allows multiple threads to read the NCB at one time which can happen when an Intellisense request is happening on the background thread and the foreground thread needs to access it as well. A classic example of this problem was getting a QuickInfo tooltip. The foreground thread would need to do some basic querying of the NCB to create the QuickInfo request, which would then be processed on the background thread. However, if the background thread already had the lock, then the foreground would block until the background was done. This was really noticeable when scrolling around a large function. Similar problems happened with AutoComplete requests as well.
When quickly navigating around a file, we would generate QuickInfo and CodeDefintionWindow (if the window was open) requests as the cursor touched different areas of the code. This could result in a bunch of background requests that would run and then be ignored. We made a change to only allow one of these types of items in the queue at a time.
There were a few things that were incredibly slow to change in a solution. Modifying certain options (such as adding an include directory) or changing the active configuration would take a really long time for large solutions. There was some really inefficient work going on in these cases which has been removed or redone.
“Goto Definition” in many situations will parse the file to the cursor in order to know the exact type of the identifier under the cursor. This was happening on the foreground thread and if there was a low-priority item on the background thread running, the foreground would have to wait for the background one to finish. This was changed to queue the item to the background queue, which causes any low-priority items to be aborted. As a result of this work, we had one customer reporting a two minute delay drop to 10-20 seconds.
There is now throttling of the background thread when doing most of the parsing. Even though the background was running at lower priority, there was concern about it using 100% of the CPU and some reported issues of it interfering with other applications. We now process low-priority background items (such as Intellisense population) using only ~80% of a CPU’s time. Any high-priority items (i.e. Intellisense requests) will still be processed during this time.
We changed the project system to make looking up files in projects much more efficient. This improves several scenarios such as adding files to projects, changing configurations, etc.
There is now more information displayed in the status bar. It looks like this: “Updating Intellisense… (xxx)”. The number in parentheses shows how many background thread work items are in progress. For customers that aren’t seeing Intellisense ever complete, this information may be useful.
We now display the wait cursor at times when the IDE may not be able to respond immediately. This gives better feedback to people that the IDE isn’t just hung, and may be displayed in the following situations:
· Closing a project
· “Goto Definition” is invoked or when a foreground parse is required
· After loading a solution and doing initialization
· Reparsing a solution after a configuration change
We made a variety of improvements to how the IDE handles its idle-time processing. This work involved changes to ensure that lower priority idle tasks are treated as such by the IDE, enabling longer-running idle tasks to be spread out over multiple idle cycles, and ensuring our idle logic is smart enough to break early for later completion when a higher priority task is waiting. Overall, these changes make the whole UI/editing experience smoother.
Looking up files in a project was doing just a linear search of the files. This caused big slowdowns when doing certain operations such as adding a file to a project that already contained lots of files.
· We identified a few internal algorithms that exhibited poor performance (i.e. O(N^2) or O(N^3)) at large scale and replaced these with algorithms that scale more linearly.
· We found instances of function-static data being used in multi-threaded scenarios and made these thread safe by moving this data to Thread Local Storage.
· We improved performance of an internal hash table with a better-performing hashing function that exhibits fewer collisions.
Some customers have learned to manually disable Intellisense by marking the NCB file as read-only or deleting the Intellisense engine, feacp.dll, from the vcpackages directory, but there has not been a way to control any of this from the IDE. While working on this QFE, I added a few flags that can be set using VS macros that do things such as disabling Intellisense almost completely or disallowing updates to the NCB while allowing queries. The second mode is pretty useful for large projects where Intellisense works and is useful but reparsing is painful. You can now disable updates until you have finished a bunch of edits and then turn it on and get everything parsed up-to-date. The macros that control these settings can be attached to toolbar buttons for convenient access while coding. Given how long this entry already is, I will write a separate blog on this soon.
PS: Jim wrote the subsequent macros blog and here it is: http://blogs.msdn.com/vcblog/archive/2007/11/19/controlling-intellisense-through-macros.aspx
Jens, I have the same problem with Professional...
The package installed cleanly, and it does seem to improve performance, so many kudos for that.
I was hoping it would fix the other IntelliSense-related problem I have, though, which is this: if I specify global scope using the scope operator, right after I type the second ':', VS2005 SP1 crashes[*] while IntelliSense is populating its suggestion list.
This behavior continues after the new HotFix. Oh well.
[*] Where "crashes" is defined as "Microsoft Visual Studio 2005 has stopped responding" followed by shutdown.
My main question is:
Are there significant improvements in the core c++ compiler like
a) producing faster executable code
b) significant improvement in diagnostics/static code analysis
Thanks for all of your hard work! The developers community is certainly grateful for this patch!
I've tried the patch yesterday, which by the way did install successfully on VS2005 professional (at least that’s what the install shield reported to me), and the difference is certainly noticeable! First of all let me describe the solutions that our team is working on. The solutions consists of up to 341 projects, all of which are buildable with Win32/Win64 Debug/Release configurations. Prior to the patch the after loading the solution that contains 341 projects, VS would always crash after ~5 minutes of use, so the only workaround we had was to rename the intellisense dll. But after installing this patch, I’ve been running that solution without any apparent problems. Even thought the response time has improved dramatically, I still witness ~5 second freezes with ~1 second of response time every ~6 seconds (which is an improvement from 1 minute freezes reported by our developers). This, however, is still too slow and irritating for any productive work to be done, so manually disabling the intellisense feature (or the update of intellisense) would be great. Can you please PROVIDE the details of how this can be done? You said “I’ve added a few flags that can be set using VS macros that do things such as disabling Intellisense almost completely or disallowing updates to the NCB while allowing queries” – please, please, PLEEEEEASE show how we can do this. I’ve googled and googled and still didn’t find how this is done.
Please, give informations about installing over professional SP1! (italian)
How Can I Get KoreaVersion?
DownLoad that Link. I Can't Install.
How can I remove the hotfix? Because it seems it's not compatible with the Xbox 360 SDK
Ah right, found it, forgot to check the "show updates" checkbox in the add/remove programs window ;)
But this sucks. After uninstalling the hotfix the XDK still complains, and I can't reinstall the XDK because it says "some files have changes". I am now in the tedious process of reinstalling VS 2005 SP1, which takes a long, long time. Another day wasted doing nothing. Yay.
Jim Springfield: You and the VC++ team did a good job on this hotfix! IDE performance has noticeably improved when loading and working with VC++ projects. You guys are definitely doing some good work cleaning up some massive kludges. That said, performance is still very poor compared to VS 6 which really does fly like greased lightning. Will there be more VC++ performance hotfixes?
I genuinely appreciate that MS appears to have re-started investing in native VC++. My sincere hope is that we (native VC++ developers) are not getting Windows ME-d with perf improvements and MFC additions.
Also, while we are discussing performance I have a serious question: Is there any chance the Visual Studio team (or at least the VC++ team) will have something of major Performance reset, where performance is considered across the board and everything stops until all aspects of performance are reviewed and addressed? (IDE perf, libraries perf, mfc classes perf, compiler perf, etc). I ask b/c I know Microsoft has a serious Security initiative (b/c executives recognize the criticalness of Security, and that security must be baked-in). What are you doing to bake-in performance?
Jim Springfield: Thank you and your team so much! The performance difference is noticeably better. Even more important (for me) is that now a number of the Intellisense features now *work* for a specific project I'm working on. Many of these features have not worked for this project in the 5 years it's been under development!
Anyone here who tried the patch with VS2005 Professional? ...
Yes. Works fine with VS2005 Professional SP1 English versions on XP and Vista.
Please, if I could just have control over intellisense, I would be satisfied - I would like the ability to
1. manually freeze intellisense into a read-only mode,
2. manually refresh intellisense db if I feel it is necessary.
That's exactly what I was wishing ever since I started using VS2005. I believe one of Intellisense's major problems is trying to do too much too often.
Still, it chickens out on the first simple template declaration it encounters... :/
Jim Springfield: You mentioned those MACROS on several occasions. If you could finally drop some info on how to access them, pleeeaaaase?
I completely agree with Jared's statement "performance is considered across the board and ... all aspects of performance are reviewed and addressed".
1. Improve compiler generated machine code performance
2. Dramatically improve static code checking / compile time warnings / diagnostics
3. Produce code complexity metric / code quality metrics. We want to integrate this into our build process so that no code gets checked in until it a) builds without error and b) does not get flagged with bad code metrics (too complex, unmaintainable, etc). This would essentally take a FxCop type of output and filter it for a set of errors before code checkin.
4. (Nice to have) Refactor method to convert a member function to a static method. We are finding it much easier to maintain static member functions since the method does not depend on any context from the class.
For #4, our code was written over the last 10 years and many many of our classes are used essentially like a simple function call.
a) allocate/construct class
b) set member variables
c) call member function
d) de-construct/deallocate class
This type of code is bloated when the constructor and set member variables (parts a and b) only just set member variables and do no real work. We end up having at least 4 function calls made (a,b,c,d) just to call a simple member function in that class. Converting that to a single static member function a) eliminates the 4 function calls, b) improves performance (compiler can better optimize the static call) and c) (most importantly) is easier and lower cost to maintain.
This cuts about 5 to 10 lines of code out every time the function is called and, over a large project ~150,000 lines of code, saves several thousand lines of code.
This is much more maintainable for us.
Hi, my name is Jim Springfield, and I’m an architect on the Visual C++ team. When I recently blogged
Geez, what's happening? Just figured out by chance that you have to click on either of the above "names" (Visual C++ Team Blog / Noticias externas) to get to the "Controlling IntelliSense Through Macros" page. That's weird, but hey, thanks Jim! :)