Are you tired of waiting for your conditional breakpoints to hit in C++? Do you wish there was a way to speed up the debugging process and get to the root of the problem faster? If so, you’re in luck!
We have some exciting news for you: Visual Studio 2022 has significantly improved the performance of conditional breakpoints in C++ through a reworked implementation. This means you can now debug your C++ code faster and more efficiently than ever before.
What are conditional breakpoints?
Conditional breakpoints are a powerful debugging tool that only triggers when a specified condition is met. For instance, you can set a conditional breakpoint to pause your program’s execution when a variable reaches a certain value or when an expression evaluates to true.
These breakpoints are particularly useful for debugging complex scenarios, allowing you to concentrate on specific cases or situations. They help you avoid unnecessary steps and iterations, making your debugging process more efficient and focused.
How did we improve them?
We revisited the implementation and looked for potential improvements that could be made around the hot path for conditional breakpoints. Since the implementation can be very specific to the target language, we started by focusing on the C++ experience.
We realized that a lot of the expensive fetch operations made to the process memory and CPU registers can be cached while on the same break state. This improvement also impacts the regular debugging experience and is not limited to the conditional breakpoints.
We also revisited how we notify the debugger that a break has happened. Most of these operations can be delayed after the condition is evaluated or skipped altogether when the breakpoint condition is false, for example.
We also reduced the overall processing such that we only fetch the minimal information needed for evaluating the breakpoint condition, such as when retrieving the call stack information or when retrieving the necessary registers from the CPU.
How much faster are they now?
Our initial assessment indicates a performance improvement of at least 35% in version 17.10 and 70% in version 17.11 Preview 2. The benchmark application consists of a while loop that iterates 80,000 times before hitting the breakpoint, once the condition is met. We reduced the execution time from 80 seconds to 21 seconds.
You can see the difference in performance in the video below. The left side shows the conditional breakpoints performance in version 17.9, while the right side shows the performance in version 17.11 Preview 2 onwards.
How can you try it out?
If you want to try out the enhanced conditional breakpoints performance in C++, you need to have Visual Studio 2022 version 17.11 or higher installed on your machine.
Once you have installed Visual Studio 2022, you can set conditional breakpoints in C++ as usual. To set a conditional breakpoint, right-click on the breakpoint icon in the editor and select “Conditions”. Then, enter the condition you want to apply to the breakpoint and click OK.
You can also edit or remove the condition of an existing breakpoint by right-clicking on the breakpoint icon and selecting Edit Conditions or Delete Condition.
We want to hear from you!
We hope you find the enhanced performance of conditional breakpoints in C++ beneficial for your debugging needs. Our commitment to making Visual Studio better and faster for you drives us to continuously seek your feedback and suggestions.
If you have any comments, questions, or issues regarding conditional breakpoints in C++ or any other feature of Visual Studio, please let us know via the Report a Problem tool in Visual Studio.
Stay connected with the Visual Studio team by following us on Twitter @VS_Debugger, Twitter @VisualStudio, YouTube, and LinkedIn.
Thank you for using Visual Studio, and happy debugging!