slow compile time on IIS server

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
1/13/2012 1:45:56 PM
Gravatar
Total Posts 130

slow compile time on IIS server

Hello,

Has anyone observed slow compilations (1-2 minutes per site) with v 2.3.7.6 in IIS? I've reconfigured my mojo sites in IIS to one site with host headers handling the domains for the child sites.  Even still, compilation is taking far too long and is maxing out the server CPU ... and half the time is freezing the server, requiring a reboot.

In a dev environment I've been playing with deploying both my old (v 2.3.5.3) and new (v 2.3.7.6) versions. When the first site compiles it barely uses more than 60% cpu for less than five seconds.  The new version, however, is maxing out the cpu at 100% for 1-2 minutes.

Has anyone else experienced this?

I'm running in IIS 7 v4.0 integrated on a Windows Server 2008 Enterprise.

Thanks,

Beth

1/13/2012 1:56:21 PM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

Can you try the following and see if it helps:

1. Remove extra .resx files under /App_GlobalResources for languages you don't need. ie the English ones are named with just .resx while other languages are named with .cutlurecode.resx

The number of translations has grown quite a lot and I'm pretty sure those files have to be compiled by the asp.net compiler, so in theory that could be a big factor.

2. Remove any extra skins that you ar enot using both from /Data/skins and from the site specific folders. Every additional folder requires some compilation.

Please do those one at a time and let me know how much improvement each seems to produce. 

Thanks,

Joe

1/13/2012 2:12:56 PM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

Another avenue to explore is pre-compiling before deployment, but it requires using the Visual Studio command prompt. I have not tried it yet myself, but its something I may look into. There is an overview article here.

Best,

Joe

1/13/2012 2:56:21 PM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

It seems that VS doesn't have built in support for pre-compiling web app project types but it does have support for pre-compiling web site projects types.

So, one experiment that is easy to try, first deploy to a local folder, then, remove all the skins (because we don't want it to compile all the layout.master files), then open that folder as a web site in VS, and choose publish web site, uncheck the box that says "Allow this pre-compiled site to be updated", and it seems to pre-compile everything into the bin folder including the .ascx, .aspx, .resx files. If you open them in a text editor you'll see they are empty. This is because of the checkbox about not allowing them to be updated. Then put the skins back, and in theory it should work and it should load much faster because there is very little remaining that would need topbe compiled on demand such as the layout.master files.

I'll try this myself when I get chance, I tried the compiling part just not tried running it yet and I'm kind of behind on some things I'm working on so I won't get to it today.

Best,

Joe

1/13/2012 2:57:36 PM
Gravatar
Total Posts 130

Re: slow compile time on IIS server

Hi Joe,

I couldn't find any files with .cutlurecode.resx extensions in the App_GlobalResources directory or anywhere else in the project.

The Sites directory has been moved to a fileshare so are not present on compilation.

I'll look at the article you linked.

Thanks,

Beth

1/13/2012 3:05:58 PM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

By culture codes I meant like Resource.resx is English , and Resource.ru.resx is Russian, and Resource.pt-BR.resx is Brazilian Portuguese. There should be lots of different files like BlogResources.resx is the English file for the blog feature, and BlogResources.ru.resx is the Russian version. So you can try removing all but the English versions. So culturecode was just a place holder for the actual language culture code.

However my last post should in theory also work and all of the resource files will be pre-compiled and the resulting package won't even have an App_GlobalResources folder since they are all pre-compiled in the /bin folder.

You would want to remove the /Data/skins folder before pre-compiling even if you already remove the site folders before compiling, then put it back after compiling. When I get a chance I'll give it a full test myself and if it works I'll write a document about it.

Best,

Joe

1/13/2012 3:07:53 PM
Gravatar
Total Posts 130

Re: slow compile time on IIS server

I can tell my brain is fried ... haha, thanks for explaining!

I'll let you know what I come up with ...

~ B

1/16/2012 8:05:51 AM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

I did some experimenting with pre-compiling over the weekend.

Really Web Application projects like mojoPortal are pre-compiled already in the sense that all the .cs files are pre-compiled into dlls in the /bin folder, but all the files like .aspx, .ascx, .asax, .resx are not pre-compiled so those files normally need to be compiled by the ASP.NET compiler. Those files can be thought of as partial classes just like .designer.cs files are partial classes to a page or control, the .aspx or .ascx etc is compiled also as a partial class corresponding to the code behind .cs file that is already compiled in the bin.

So taking the deployment package and opening it as a web site (rather than a Web App Project which it was before deployment), it is possible to further pre-compile the .ascx, .aspx, .resx etc files by publishing it again while treating it as a web site project rather than a web app project. 

However in my tests I discovered that one problem with pre-compiled sites is that VirtualPathProviders do  not work, even the documentation on VirtualPathProviders here mentions that they do not work in pre-compiled apps. Since we use a VirtualPathProvider to map the theme.skin files from the skin folders, the result is errors that the theme compiler could not find the theme. From further googling I found a workaround that does work, but it uses reflection and therefore can only work in Full Trust hosting because reflection is not allowed in Medium Trust. I'll list the steps here in case you want to try it for your deployment.

1. Produce a build the normal way and deploy it to a local folder

2. Move the Data folder to another location because it doesn't work if the skins are are included, so remove it from the initial deployment folder.

3. Open the initiall deployment folder in VS as a Web Site

4. This part is the workaround, right click the web site in VS and choose Add ASP.NET Folder, and choose App_Code. Add a new item to the App_Code folder, chooose class, and name it AppInitVPP.cs, and paste in the following code:

using System.Web.Hosting;
using System.Reflection;
using System.Collections.Specialized;
using mojoPortal.Web;

public static class AppStart
{
public static void AppInitialize()
{
// we create a new instance of our own VirtualPathProvider.
mojoVirtualPathProvider providerInstance = new mojoVirtualPathProvider();
// any settings about your VirtualPathProvider may go here.

// we get the current instance of HostingEnvironment class. We can't create a new one
// because it is not allowed to do so. An AppDomain can only have one HostingEnvironment
// instance.
HostingEnvironment hostingEnvironmentInstance=(HostingEnvironment)typeof(HostingEnvironment).InvokeMember("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);
if (hostingEnvironmentInstance== null)
return;

// we get the MethodInfo for RegisterVirtualPathProviderInternal method which is internal
// and also static.
MethodInfo mi = typeof(HostingEnvironment).GetMethod("RegisterVirtualPathProviderInternal", BindingFlags.NonPublic | BindingFlags.Static);
if (mi == null)
return;

// finally we invoke RegisterVirtualPathProviderInternal method with one argument which
// is the instance of our own VirtualPathProvider.
mi.Invoke(hostingEnvironmentInstance, new object[] { (VirtualPathProvider)providerInstance });
}
}

5. Right click the web site and choose Publish Web Site. Leave the box checked that says "Allow this precompiled site to be updateable". Choose another folder to deploy to and choose ok. (Note that this means the .aspx and .ascx files are not really going to be pre-compiled, but .resx files will and it still should load faster on startup. If you uncheck the box, then all of the deployed .aspx and .ascx files are empty if you open them in a text editor, but in my testing it did not work correctly doing that. It seemed like it was not laoding the right master page and the column layout was not working, but if you leave it updateable it works.

6. Restore the /Data folder to the new deployment folder and now the package is ready for actual deployment.

In Full Trust it works for me but in Medium Trust it throws a security exception due to the use of reflection.

All in all, I'm pretty sure that the slower startup time is caused by the increased number of .resx files as we've added more and more translations. So removing languages that you don't need from /App_GlobalResources is probably going to be almost as helpful as trying this process of pre-compiling, and less complicated, but it is an option if removing the extra .resx files doesn't improve things enough. You could write a script to automate the removal of non-English .resx files if English is the only language you need. Note also that adding or removing files from the /App_GlobalResources folder causes the app to restart the same as touching a web.config file.

Hope that helps,

Joe

3/21/2012 9:25:04 AM
Gravatar
Total Posts 130

Re: slow compile time on IIS server

Hi Joe,

Thanks for investigating the issue.  I've tested out removing the resource files and additional skins, as well as precompiling.  The first method did help, although it maxed out my server resources for close to a minute. Precompiling went smoothly and barely affected resources at all when loaded in IIS.  It is the method I will be using in the future.

My testing was done in a dev environment, so the real test will be deploying to a live server, but I am hopeful.  If I run into any oddities or trouble I'll let you know.

Cheers,

Beth

3/21/2012 9:30:30 AM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

Glad to hear that worked. So you used the workaround for VirtualPathProviders to make the skins work correctly?

Best,

Joe

3/21/2012 9:44:53 AM
Gravatar
Total Posts 18439

Re: slow compile time on IIS server

Hi Beth,

I would do thorough testing before deploying it to production just to make sure the pre-compilation process did not result in any anomolies and that all features still work as expected. I'm not really officially recommending this solution, it is not something I can support very well if people have any problems that I cannot produce without doing this pre-compilation. So I'm not saying this is a supported way to deploy mojoPortal, it may work well or it may result in strange bugs, but if it does result in strange bugs there is not much I can do about it since mojoPortal is really a web application project not a web site project and web application projects don't support that fully pre-compiled output. So this pre-compiled deployment approach is a your mileage may vary kind of thing.

Best,

Joe

3/21/2012 9:58:13 AM
Gravatar
Total Posts 130

Re: slow compile time on IIS server

Hi Joe,

Yes, I used the Workaround for the VirtualPathProviders and the skins are loading.  When I tested this out, I just made sure the site would load, but didn't go any further than that (logging in, trying out modules, etc).  I'll actually test out site functionality to make sure everything is in place. I understand that you can't officially support or suggest this method of compilation.  I'll let you know if anything weird is going on, just so you know.

~ Beth

You must sign in to post in the forums. This thread is closed to new posts.