Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes a page to render slow?

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?

like image 719
Olivier Tremblay Avatar asked Jul 08 '09 12:07

Olivier Tremblay


2 Answers

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....

like image 200
Davide Vosti Avatar answered Nov 15 '22 21:11

Davide Vosti


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.

like image 27
Andrew Hare Avatar answered Nov 15 '22 19:11

Andrew Hare