是否.NET code运行的CLR调试慢附加到进程? [英] Does .NET code run slower with the CLR debugger attached to the process?

查看:142
本文介绍了是否.NET code运行的CLR调试慢附加到进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pretty的多是什么标题说:我运行一个长的节目,它有附加的CLR调试,这样我就可以捕获并检查异常。我收到性能堪比没有调试器中运行它,或者是有严重(2-10x或更多)罚我付?

Pretty much what the title says: I'm running a long program, and it has the CLR debugger attached, so I can catch and inspect exceptions. Am I getting performance comparable to running it without the debugger, or is there a serious (2-10x or more) penalty I'm paying?

推荐答案

的大问题:工具+选项,调试,一般,在模块加载苏preSS JIT优化。你想要的关闭,如果你想调试版本code和获得媲美PERF。但这却使其难以调试code时,JIT优化器将存储在CPU寄存器局部变量(手表将无法正常工作),并重新排序和内嵌code(步进行为怪异)。

The biggie: Tools + Options, Debugging, General, Supress JIT optimization on module load. You want that off if you want to debug release code and get comparable perf. That does however make it harder to debug your code, the JIT optimizer will store local variables in CPU registers (Watch won't work) and reorder and inline code (stepping acts weird).

再有就是DebuggableAttribute,由编译器自动生成。其IsJITOptimizerEnabled和IsJITTrackingEnabled性关系。其一,他们的工作,以保持局部变量活着只是一丁点时间超过必要,preventing从收集,你可能想在调试器中检查引用垃圾收集器。容易避免,只是调试发布版本,而不是调试版本。

Then there's the DebuggableAttribute, automatically generated by the compiler. Its IsJITOptimizerEnabled and IsJITTrackingEnabled properties matter. For one, they work to keep local variables alive just a wee bit longer than necessary, preventing the garbage collector from collecting references that you might want to inspect in the debugger. Easy to avoid, just debug the Release build instead of the Debug build.

再有就是具体的东西发生在你的程序唤醒调试器,并使其窃取CPU周期:

Then there is specific stuff that happens in your program that wakes up the debugger and make it steal CPU cycles:

  • 当你的程序会引发异常。调试器得到了一枪,就被扔了。被称为第一次机会的通知,你看到它在输出窗口。这是什么使得调试+异常对话工作。减慢异常处理了很多。
  • 当你的程序加载或卸载DLL。很多事情发生在加载时,调试器将尝试找到该DLL的符号。检查是否有任何断点需要被激活。并显示在输出窗口的通知。这通常只是使你的程序的启动速度慢,尤其是当你已经有了混合模式调试打开。
  • 当您使用跟踪类的DefaultTraceListener,Debug.Write /线()方法或Console.Write /线路启用宿主进程。输出出现在输出窗口,减慢这些调用了很多。
  • 在当前程序中的一个线程启动或停止。可见在输出窗口。闻听此事减慢你的程序将是一个设计错误。

这就是它,调试器撑出的方式,让您的$ C全速$ C运行,只要它没有做什么上面列出。运行时环境,如ASP.NET和Silverlight是特殊的,可能有额外的开销。因此,它在64位操作系统,需要远程调试器,因为VS是只有32位的调试任何CPU的程序。

That's about it, the debugger stays out of the way and lets your code run at full speed as long as it doesn't do what's listed above. Runtime environments like ASP.NET and Silverlight are special and probably have additional overhead. So does debugging an Any CPU program on a 64-bit operating system, that requires the remote debugger because VS is 32-bit only.

这篇关于是否.NET code运行的CLR调试慢附加到进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆