views:

601

answers:

6

I am puzzled. I looked at the trace of a pagecall that was "slow" to load according to my boss, causing the page to partially load, and then "jump" to the memorized scroll-place on a postback.

I found out eventually, using my trace, that my whole loading, from Begin PreInit to End Render, took 1.94 seconds, 1.5 of which are spent between Begin PreRender and End PreRender.

Any idea on what could cause that? The next biggest loadtime is 0.14 seconds, for End PreRenderComplete.

Could the problem originate from my queries to SQL Server, or a too vast quantity of controls on the page, even though most are "hidden"?

[edit:]It seems that my page load is very long when I show a certain form. My total render size is of 91537 bytes, 44483 of which are dedicated to that specific form. My viewstate seems kindof enormous. Also: Can a 404 to a JS file cause that kind of lag on load?

[update:] So I found the longest-running query, and it seems that even though it DOES seem quite chunky, it has ended running long before the page is even loaded. As added information: I am using quite a bit of SqlDataSources troughout the controls, to fill my dropdownlists and other interesting stuff of the like. Is that cluttering my app?

+3  A: 

In order to identify the cause of a bottleneck you really ought to profile your code with a tool like ANTS Profiler or something similar.

A profiler will allow you to pinpoint the problem area by showing you which lines of code are slower than others.

Andrew Hare
Anything I don't have to spend 400 dollars on to find a single problem in this application? :P
MrZombie
I thought you can try ANTS Profiler by just downloading it :).Similarly, you can download Visual Studio trial and give the VS profiler for free as well.
Jimmy Chandra
I've used a trial of ANTS Profiler as well as Visual Studio's Performance Wizard and found them to be comparable in many ways.
Saul Dolgin
ANTS was simply a suggestion - there are many alternatives. This site has many questions regarding .NET profilers.
Andrew Hare
+4  A: 

In my experience (same problem as you), it's 90% a SQL issue.

Put some Stopwatch(es) around the query you are calling to find out which query is running slow.

Rendering asp.net control can't take so long....

Davide Vosti
Rendering ASP.NET controls CAN take long considering that a control can be quite complicated (think of some of the Telerik ajax components, etc).
Saul Dolgin
I agree with this. Especially if you are using any of the Data Source controls. Run SQL Profiler while running the app.
Chris Lively
Oh, so SQLDataSource != Good idea?
MrZombie
I think it depends on the volume of data you are retrieving. If your queries just return a bunch (up to hundreds) SQLDataSource are still good. Tune your query with the profiler and be sure to retrieve only the data you are showing on the page. If you are 100% sure that your query runs fast,look somewhere else.
Davide Vosti
Finally found the culprit: It IS a query. Thanks for that :P
MrZombie
+2  A: 

I would use YSlow to determine if its from something on the client side or server side. We sometimes add timers to some queries then output the time to execute in an html comment... of course removing them when the testing is complete.

Does the page call anything hosted on an external site?

Chris Klepeis
if the problem can be traced to somewhere between preinit and endrender, there's probably not much yslow can do in this particular case. but i'll second that it's still a good tool, and a relevant answer to the more generic question in the title
David Hedlund
A: 

Your best bet is to use the Perfomance Wizard in Visual Studio and look at the Call Tree for your page. It will give you more details into the exact performance bottleneck.

I have seen this type of performance when there are too many complex controls declared on the page. Although it could easily be SQL related as well. To know for certain you need to look at the Call Tree and find out what the most expensive call is.

Saul Dolgin
A: 

Of course, if it is sql-related, as many people have noted, "sql server profiler" is the tool to use (given that you're running mssql). mysql has "jetprofiler" (.com) which i haven't tried. once you've found the slow query, it's not rarely an indexing issue.

David Hedlund
A: 

Check this out...

http://www.dotnetscraps.com/dotnetscraps/post/How-to-troubleshoot-issues-with-Page-Rendering-in-ASPNET.aspx

Rahul Soni
Could have been useful. If it hadn't been almost 6 months. :P
MrZombie
Sorry about the delay man :) I didn't notice the time...
Rahul Soni