【发布时间】:2017-06-14 19:10:39
【问题描述】:
我们在 Form 的 Load 事件处理程序中构建了 29 个用户控件(每个都包含许多其他标准和用户控件)。
禁用优化(在调试模式下或在发布模式下的高级编译器设置中)这大约需要 7 秒。启用优化后,这大约需要 50 秒。这只发生在我们的一台未连接互联网的实验室机器上;我的机器上的启动时间或发布和调试大致相同。我们的目标是来自 Visual Studio 2015 的 .NET Framework 4.5 x64。
使用远程调试器并定期暂停,这似乎是由 JIT 在代码实例化每个用户控件之前使用大量 CPU 时间引起的。有什么想法可能导致这种情况吗?
似乎大部分时间都在使用的 JIT 函数的堆栈跟踪:
clrjit.dll!THX_NColBestCoverage(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,class hashBv *,unsigned int,unsigned int,int *,struct CI_TAG *)
clrjit.dll!THX_NColDeterminePhysregAvail(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,class hashBv *,unsigned int,unsigned int,struct tagSYM *,int *,int *,struct CI_TAG *)
clrjit.dll!THX_NColProcessCandidateRegion(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,struct tagNCOLREGION *,struct tagNCOLUSEBENEFITS *,struct tagTUPLE *,int,struct tagNCOLPHYSREGAVAILS *,struct CI_TAG *)
clrjit.dll!THX_NColor(struct tagFUNC *,struct CI_TAG *)
clrjit.dll!THX_dop2_CodegenUpdate(struct tagFUNC *,struct CI_TAG *)
clrjit.dll!THX_dop2(class JitContext *,struct CI_TAG *,unsigned char * *,unsigned int *)
clrjit.dll!PreJit::compileMethod(class ICorJitInfo *,struct CORINFO_METHOD_INFO *,unsigned int,unsigned char * *,unsigned long *)
[Managed to Native Transition]
【问题讨论】:
-
如果没有看到负载处理程序中的代码,很难推测。由于这是 64 位,一种可能性是负载处理程序中发生的臭名昭著的异常吞噬。代码是否包含在 Try-Catch 块中以检测异常?作为一种解决方法,您可以使用 `
' 属性对方法进行代码装饰。
标签: .net vb.net winforms performance