C#Web应用程序调优:PerformWaitCallback

Fra*_*ois 13 c# asp.net profile profiling dottrace

我使用dotTrace Performance 4.5来分析.NET 3.5 C#Web应用程序.当我记录一个"用户请求"(页面加载)时,我看到11个线程具有大致相同的时序,7644毫秒.

  • 大多数线程描述仅包含: 100%[本机或优化代码] - 7644 ms
  • 一说: 100%Microsoft.VisualStudio.WebServer.WebServerApp.Main(String[])
  • 最后一条是:
    • 86% System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object)
    • 14%PerformWaitCallback(1094毫秒)>> 12%=ProcessRequest

你能告诉我吗:

  • 为什么有那么多线程?(图片资源,AJAX,JavaScript)
  • 什么是PerformWaitCallback
  • 为什么7644毫秒只有1094毫秒的工作?

Oha*_*der 1

关于PerformWaitCallback,参考资料来源是这样说的:

回电帮手。该函数将请求分派给用户回调。循环中从每个应用程序域队列中获取工作项,直到没有更多工作或量程已过期。强制执行量子数是为了维护应用程序域之间的公平性。

您可以在此处查看完整的代码。

顺便说一句,我不确定您是否会在 .NET 4.5 中看到这一点 - 再次从参考源(无法找到在线版本,您必须从http://referencesource.microsoft.com/下载它) ):

//This type is necessary because VS 2010's debugger looks for a method named 
///_ThreadPoolWaitCallbacck.PerformWaitCallback 
//on the stack to determine if a thread is a ThreadPool thread or not.  
//We have a better way to do this for .NET 4.5, but
//still need to maintain compatibility with VS 2010.  
//When compat with VS 2010 is no longer an issue, this type may be removed.
internal static class _ThreadPoolWaitCallback
{ 
    [System.Security.SecurityCritical]
    static internal bool PerformWaitCallback() 
    { 
        return ThreadPoolWorkQueue.Dispatch();
    } 
}
Run Code Online (Sandbox Code Playgroud)