Reputation: 12694
I have an ASP.Net application that takes an unusually long time to start up the first time it is accessed. I did some tracing and I found that 57 seconds are spent in this function:
Boolean System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection)
and that function in turn calls the following one 6 times:
Void System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder)
My question is what does System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder
do? My web application is already compiled, I don't know why it is doing any kind of compilation work on start-up. Is this normal? Is there something going on that I don't know about?
Upvotes: 4
Views: 5220
Reputation: 944
Check index.aspx or default.aspx to see if there are any web applications. Sometimes it takes time to find the files, and compilation takes a while only first time.
Upvotes: 0
Reputation: 115
AFAIK, ASP.NET is based in the .NET world of doing things. Which, of course, means that there's actually two parts to compilation. One is that you compile the source into the .NET bytecode format. Second is the actual conversion into a format suitible to actually run on your system, usually in a Just-In-Time fashion. This is similar to Java, though there's a lot of lower-level differences.
The issue is that it's currently doing this JITting up-front, which is by design. It can take a while to get the ASP.NET app up and working, which is the minute you're seeing. I do believe there is a way to enable pre-JITting prior to having someone actually visit the site, but I'm not sure of the exact manner. Hopefully someone will post/link to the actual method for doing it.
Upvotes: 1
Reputation: 61617
There is quite a bit of bootstrapping that occurs when an ASP.NET application is started. This includes the worker process kicking in, assemblies loaded into the AppDomain
, and also compilation of files in the current directory. This batch compilation process is per folder, which means if I request /
for the first time, the batch compiler will scan the folder for supported types, compile them, and cache the result. This is only done within the root /
folder. My first request to another /OffRoot
folder will result in another batch compile.
If you have a precompiled site, the runtime still performs this type of scan but determines that it doesn't have to compile anything.
There is an important difference between a pre-compiled Website, and a compiled Web Application. A pre-compiled Website will have this first-instance compilation done ahead of time, so it need only load the assemblies into the AppDomain
where it needs to. With a compiled Web Application, you have compiled base source code, but the views (.aspx
) files are not compiled, so it still does that first-time compilation (dynamic compilation).
Upvotes: 5