How to make MSVC debug builds run faster

后端 未结 8 2058
日久生厌
日久生厌 2020-12-31 08:54

We have a large C++ application, which sometimes we need to run as a debug build in order to investigate bugs. The debug build is much much slower than the release build, t

相关标签:
8条回答
  • 2020-12-31 09:29

    profile the app and see what ti taking the time. you should then be able to see what debugging need to be tuned.

    0 讨论(0)
  • 2020-12-31 09:29

    Create a ReleaseWithSymbols configuration, that defines NDEBUG and has no optimisations enabled. This will give you better performance while maintaining accurate symbols for debugging.

    0 讨论(0)
  • 2020-12-31 09:36

    there are several difference between debug builds and release builds that influence both debugability and speed. The most important are the _DEBUG/NDEBUG define, the compiler optimizations and the creation of debug information.

    You might want to create a third Solution Configuration and play around with these settings. For example, adding debug information to a release build doesn't really decrease performance but you already get a sensible stack trace so you know which function you are in. Only the line information is not reliable because of the compiler optimizations.

    If you want reliable line information, go on and turn off optimizations. This will slow down the execution a bit but this will still be faster than normal debug as long as the _DEBUG define is not set yet. Then you can do pretty good debugging, only everything that has "#ifdef _DEBUG" or similar around it won't be there (e.g. calls to assert etc.).

    Hope this helps,

    Jan

    0 讨论(0)
  • 2020-12-31 09:37

    Which VS are you using? We moved from VS.net to VS2008 recently and I experienced same slowness while debugging on high end machine on > 500k LOC project. Turns out, Intellisense base got corrupted and would update itself constantly but get stuck somewhere. Deleting .ncb file solved the problem.

    0 讨论(0)
  • 2020-12-31 09:38

    Are you using MFC?

    In my experience, the main thing that can make a debug version slow is the class validation routines, which are usually disabled in release. If the data structure is at all tree-like, it can end up re-validating subtrees hundreds of times.

    Regardless, if it is, say, 10 times slower than the release build, that means it is spending 1/10 of its time doing what's necessary, and 9/10 doing something else. If, while you're waiting for it, you just hit the "pause" button and look at the call stack, chances are 9/10 that you will see exactly what the problem is.

    It's a quick & dirty, but effective way to find performance problems.

    0 讨论(0)
  • 2020-12-31 09:45

    Why don't you just switch on debug information in your release configuration?

    0 讨论(0)
提交回复
热议问题