4

I've got a strange problem; normally when you set debug=false in your web.config file and compile your web application in Release mode, it increases performance. For some pages on my site, it's majorly slowing down the rendering. Here's the page in debug mode:

Debug mode on

... and here's that same page in Release mode with debug mode turned OFF:

Debug mode off

No, I didn't get those two confused. What on Earth could be causing debug mode to be rendering the page 3 times quicker (if you ignore the controller and SQL performance, it renders the page FIVE times quicker)?! Is there anything obvious I could have misconfigured?

Jez
  • 27,951
  • 32
  • 136
  • 233
  • is the 1422.5 ms on release time pretty consistant ? or just the first time ? – Scott Selby Apr 30 '13 at 14:32
  • 3
    You can use MiniProfiler to profile code on your views as well. I'd be tempted to add some profiling code around some of your code to see if you can isolate where the slowdown is being encountered. – Steven V Apr 30 '13 at 14:42
  • the biggest boost in terms of mvc when you compile the site, is it isn't dynamically compiled on first hit and the razor views are cached. show time with children should show up the speed increase in the FindView handler. Other than that, it is down to looking at other things, like is the release db configuration the same etc etc – Slicksim May 01 '13 at 08:23

1 Answers1

8

Short answer: the problem was Microsoft.AspNet.Web.Optimization beta2; it is doing something extremely inefficient and will add a second onto your page rendering time. If you're using it, upgrade. Now.


I took Steven's advice and used MiniProfiler to see what was causing the slowdown in the view. It was the System.Web.Optimization.Scripts.Render() rendering of the jQuery UI JS:

Rendering time before

As per the advice of this question (also, this question seems to address the issue), I upgraded:

PM> Update-Package Microsoft.AspNet.Web.Optimization
Updating 'Microsoft.AspNet.Web.Optimization' from version '1.0.0-beta2' to '1.0.0' in project 'Bacp.Assess.Web'.

This upgrades both Microsoft.AspNet.Web.Optimization and WebGrease. Here's the same page after I upgraded:

Rendering time after

Uhm. :-) I just knocked 99.9% off the rendering time of the page. Other pages on my site are rendering a lot quicker too. I don't know what Microsoft.AspNet.Web.Optimization beta2 was doing but it's like a ball and chain around ASP.NET!

Community
  • 1
  • 1
Jez
  • 27,951
  • 32
  • 136
  • 233
  • The release notes for beta3 are "bug fix to correct bundles being rebuilt on every request". That sounds like it would be a slow operation. https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0-beta3 – thelem Oct 28 '19 at 16:41