Conditional Breakpoints Performance Improvement
Debugging C++ code can be a time-consuming process, especially when dealing with complex scenarios. As a developer, it’s frustrating to go through extensive setup and wait for a specific conditional breakpoint to trigger so you can analyze your application in a specific state. In Visual Studio 2022 version 17.10, we optimized the implementation of conditional breakpoints in C++ to enhance performance. We further improved this in version 17.11 to boost performance even more.Â
Key ImprovementsÂ
Conditional breakpoints in Visual Studio for C++ pause code execution when specific conditions are met, making debugging targeted and efficient. For more details on how conditional breakpoints work, please refer to the Breakpoint Condition documentation.Â
Our goal was to reduce the runtime overhead of conditional breakpoints and get you to a triggered breakpoint faster. We achieved this by implementing several key improvements:
- Caching Fetch Operations: Previously, every time a breakpoint was hit, expensive fetch operations accessed memory and CPU registers. These operations were time-consuming and impacted overall debugging performance. Now, Visual Studio caches these fetch operations during the same break state, benefiting both conditional breakpoints and regular debugging scenarios.Â
- Notifications to the Debugger: Previously, when a breakpoint was hit, the debugger was immediately notified before the condition was evaluated. This often led to unnecessary overhead and slower debugging performance. Now, we delay debugger notifications until after the breakpoint condition is evaluated. If the condition is false, the notification and related operations are skipped entirely, speeding up the debugging process.Â
- Minimal Information Retrieval: Visual Studio now retrieves minimal, crucial information for evaluating breakpoint conditions. Â
Performance GainsÂ
So, how much faster are conditional breakpoints now? Our assessment reveals the following improvements:Â
Visual Studio version 17.10: At least a 35% performance boost compared to Visual Studio version 17.9.Â
Visual Studio version 17.11 Preview 2: 70% improvement compared to Visual Studio version 17.10.Â
To put this into perspective, we have tested this perf improvement in a benchmark application with an 80,000-iteration while loop. The breakpoint triggers once the specified condition is met. Previously, this process took 80 seconds. However, with the enhancements, the execution time is 21 seconds. We conducted our performance measurements on the same local machine, comparing different versions of Visual Studio while executing the same breakpoint activity. Â
For detailed instructions on how to try out this performance improvement, please visit the Accelerate C++ Debugging with Enhanced Conditional Breakpoints blog post.Â
GitHub Copilot Generated Breakpoint Expressions
In Visual Studio version 17.11 Preview 1, we’ve introduced AI-generated expressions for breakpoints and tracepoints. These tools allow GitHub Copilot to analyze your code and suggest expressions for breakpoints and tracepoints. By leveraging this feature, you can save time and discover new approaches. For further details, check out our blog post on Supercharge C++ Debugging with AI-Generated breakpoint expressions.Â
Let us know what you thinkÂ
To access these enhanced conditional breakpoints, make sure you have Visual Studio 2022 version 17.11 or later.  We hope you enjoy these new updates. Your valuable input continuously helps us improve our product, so please share your thoughts in the comment section below, through the Developer Community, via email at visualcpp@microsoft.com, or via X at @VisualC.Â
Looking forward to your feedback!Â
Unfortunately, this now reliably crashes Visual Studio with most expressions I enter. Sometimes the conditional breakpoints hit, but like 20% of the time Visual Studio crashes in vsdebugeng.impl.dll and all my work is lost, so the feature is not usable anymore.
I'm also wondering why we still don't have data breakpoints for Read but only for Write. It's implemented via hardware breakpoints, and hardware supports Read, ReadWrite and Execute. So this is more like a...
Hi Melissa, I understand how frustrating and disruptive these crashes must be for you. We genuinely appreciate your patience and willingness to share your experience. Your feedback is extremely important to us, and we aim to resolve these issues promptly.
Could you please report this issue in the Developer Community so that we can investigate further and work towards a solution?
this comment has been deleted.