Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Gaining speed in aspx pages


Message #1 by "Kan Yu Ting" <yu-ting.kan@p...> on Mon, 17 Jun 2002 02:40:48
Hi all,

I am finding methods to speed up my application . Please give me 
suggestions.

(1) The speed for my page is relative slow (sometimes not acceptable)
    I try to add cache to my user controls (implement fragment caching).

(2) For the dataset, I am going to have data caching. How can I get the 
cache updated (say per day?)

(3) I try to find help in Trace=true and get following results. I get lost 
in some of points. First the Begin ProcessPostData Second Try and 
ProcessPostData Second Try . Why it exists?

Second I found that some components in the Control Tree with large "Render 
Size Bytes ". Am I going to minimize this size so that the page get faster?

aspx.page Begin Init   
aspx.page End Init 0.004144 0.004144 
aspx.page Begin LoadViewState 0.004395 0.000251 
aspx.page End LoadViewState 0.877411 0.873016 
aspx.page Begin ProcessPostData 0.877841 0.000430 
aspx.page End ProcessPostData 0.879132 0.001292 
aspx.page Begin ProcessPostData Second Try 0.889182 0.010050 
aspx.page End ProcessPostData Second Try 0.889630 0.000448 
aspx.page Begin Raise ChangedEvents 0.889822 0.000193 
aspx.page End Raise ChangedEvents 0.890053 0.000230 
aspx.page Begin Raise PostBackEvent 0.890243 0.000190 
aspx.page End Raise PostBackEvent 0.894263 0.004020 
aspx.page Begin PreRender 0.894556 0.000292 
aspx.page End PreRender 0.907754 0.013198 
aspx.page Begin SaveViewState 5.251624 4.343870 
aspx.page End SaveViewState 5.295165 0.043542 
aspx.page Begin Render 5.295574 0.000409 
aspx.page End Render 7.900519 2.604945 


Thanks a lot

Kan
Message #2 by Feduke Cntr Charles R <FedukeCR@m...> on Mon, 17 Jun 2002 07:50:37 -0400
Kan,

	I've done similiar to the following in my ASP.NET applications, and
have found significant performance increases.

	1. Remove ViewState from as many controls as possible.  ViewState
baggage gets big, and you seldom ever need it if you have a database on your
end.
	2. All of my lookup tables (like lookup_state and lookup_country)
are cached in the Cache[] collection.  However, the way you're supposed to
it (apparently) is to put your data sets onto disk files and the cache will
expire them and what not.  I actually place my static datasets into Cache
directly with Cache.Insert; I have an object that wraps the cache so my code
becomes something like...

myDropDownList.DataSource = Global.LookupCache.Get("LOOKUP_STATE");

and if "LOOKUP_STATE" wasn't already cached (i.e. == null) then the
LookupCache object has the recipe to get and cache this information.  If
you'd like the source code for this object, let me know.  This was the
biggest performance increase for me.

	3.	a. You'll only hurt yourself trying to figure out why there
are "Second Try" events.
		b. Try removing the ViewState and watch those render size
bytes get really small.

	Note that by removing ViewState, you must explicitly code for some
things.  For example, a DropDownList's SelectionChanged (or whatever it is)
will not fire without ViewState enabled, so you must code around this in
your Page_OnLoad event (using the Request.Form[] collection).

HTH,
- Chuck
	

-----Original Message-----
From: Kan Yu Ting [mailto:yu-ting.kan@p...]
Sent: Sunday, June 16, 2002 10:41 PM
To: ASP+
Subject: [aspx] Gaining speed in aspx pages


Hi all,

I am finding methods to speed up my application . Please give me 
suggestions.

(1) The speed for my page is relative slow (sometimes not acceptable)
    I try to add cache to my user controls (implement fragment caching).

(2) For the dataset, I am going to have data caching. How can I get the 
cache updated (say per day?)

(3) I try to find help in Trace=true and get following results. I get lost 
in some of points. First the Begin ProcessPostData Second Try and 
ProcessPostData Second Try . Why it exists?

Second I found that some components in the Control Tree with large "Render 
Size Bytes ". Am I going to minimize this size so that the page get faster?

aspx.page Begin Init   
aspx.page End Init 0.004144 0.004144 
aspx.page Begin LoadViewState 0.004395 0.000251 
aspx.page End LoadViewState 0.877411 0.873016 
aspx.page Begin ProcessPostData 0.877841 0.000430 
aspx.page End ProcessPostData 0.879132 0.001292 
aspx.page Begin ProcessPostData Second Try 0.889182 0.010050 
aspx.page End ProcessPostData Second Try 0.889630 0.000448 
aspx.page Begin Raise ChangedEvents 0.889822 0.000193 
aspx.page End Raise ChangedEvents 0.890053 0.000230 
aspx.page Begin Raise PostBackEvent 0.890243 0.000190 
aspx.page End Raise PostBackEvent 0.894263 0.004020 
aspx.page Begin PreRender 0.894556 0.000292 
aspx.page End PreRender 0.907754 0.013198 
aspx.page Begin SaveViewState 5.251624 4.343870 
aspx.page End SaveViewState 5.295165 0.043542 
aspx.page Begin Render 5.295574 0.000409 
aspx.page End Render 7.900519 2.604945 


Thanks a lot

Kan
Message #3 by "Kan Yu Ting" <yu-ting.kan@p...> on Mon, 17 Jun 2002 17:09:48
Chuck,
Thanks for your reply.
Actually i try to remove the Viewstate and get the page faster. And that's 
the program I have a datagrid need to handle the OnSelectChange event and 
retrieve all data in the selected row to textbox, radio control and 
dropdown list etc.

As you say it fails to work after removing the viewstate. You mention a 
method by "handling it Page_OnLoad event (using the Request.Form[])
collection). Can you tell me more about this Or where can I find some 
examples / tutorials.

Thanks for help

Kan

> Hi all,

> I am finding methods to speed up my application . Please give me 
s> uggestions.

> (1) The speed for my page is relative slow (sometimes not acceptable)
 >    I try to add cache to my user controls (implement fragment caching).

> (2) For the dataset, I am going to have data caching. How can I get the 
c> ache updated (say per day?)

> (3) I try to find help in Trace=true and get following results. I get 
lost 
i> n some of points. First the Begin ProcessPostData Second Try and 
P> rocessPostData Second Try . Why it exists?

> Second I found that some components in the Control Tree with 
large "Render 
S> ize Bytes ". Am I going to minimize this size so that the page get 
faster?

> aspx.page Begin Init   
a> spx.page End Init 0.004144 0.004144 
a> spx.page Begin LoadViewState 0.004395 0.000251 
a> spx.page End LoadViewState 0.877411 0.873016 
a> spx.page Begin ProcessPostData 0.877841 0.000430 
a> spx.page End ProcessPostData 0.879132 0.001292 
a> spx.page Begin ProcessPostData Second Try 0.889182 0.010050 
a> spx.page End ProcessPostData Second Try 0.889630 0.000448 
a> spx.page Begin Raise ChangedEvents 0.889822 0.000193 
a> spx.page End Raise ChangedEvents 0.890053 0.000230 
a> spx.page Begin Raise PostBackEvent 0.890243 0.000190 
a> spx.page End Raise PostBackEvent 0.894263 0.004020 
a> spx.page Begin PreRender 0.894556 0.000292 
a> spx.page End PreRender 0.907754 0.013198 
a> spx.page Begin SaveViewState 5.251624 4.343870 
a> spx.page End SaveViewState 5.295165 0.043542 
a> spx.page Begin Render 5.295574 0.000409 
a> spx.page End Render 7.900519 2.604945 

> 
T> hanks a lot

> Kan
Message #4 by Feduke Cntr Charles R <FedukeCR@m...> on Mon, 17 Jun 2002 13:20:33 -0400
Kan,

	You're pretty limited in your choices here.  Basically if you
consider ViewState stores ALL of the controls information (which is alot if
you have a dropdown with, say, 100 entries) and all you really need is the
last selected item because your page is quite capable of re-creating the
drop down data (i.e. you populate it from a database or even better a cached
DataSet) then you need to extend the DropDownList:

namespace Kan.Web.UI.WebControls
{
public class DropDownList : System.Web.UI.WebControls.DropDownList
{
	#region Private Variables
	private string _oldValue = String.Empty;
	#endregion

	#region Methods
	protected virtual void LoadViewState(object state)
	{
		_oldValue = state.ToString();
	}

	// prevent packaging everything up into ViewState
	protected virtual object SaveViewState()
	{
		// assume _value has the recent value
		return (object)_oldValue;
	}
	#endregion

	#region Events
	protected override void Page_Load(object sender, EventArgs e)
	{
		// pseudo code, you really want to look for the 
		// selected item's value for Value
		if (!_oldValue == this.Value)
			this.SelectedIndexChanged(sender, e);
	}
	#endregion
	
	// then you must tie the Page_Load event to the control's Load
	// in the proper OnInit event (web form generated...
	// this.Load += new EventHandler(Control_Load);
}
}

HTH,
- Chuck

-----Original Message-----
From: Kan Yu Ting [mailto:yu-ting.kan@p...]
Sent: Monday, June 17, 2002 1:10 PM
To: ASP+
Subject: [aspx] Re: Gaining speed in aspx pages


Chuck,
Thanks for your reply.
Actually i try to remove the Viewstate and get the page faster. And that's 
the program I have a datagrid need to handle the OnSelectChange event and 
retrieve all data in the selected row to textbox, radio control and 
dropdown list etc.

As you say it fails to work after removing the viewstate. You mention a 
method by "handling it Page_OnLoad event (using the Request.Form[])
collection). Can you tell me more about this Or where can I find some 
examples / tutorials.

Thanks for help

Kan

> Hi all,

> I am finding methods to speed up my application . Please give me 
s> uggestions.

> (1) The speed for my page is relative slow (sometimes not acceptable)
 >    I try to add cache to my user controls (implement fragment caching).

> (2) For the dataset, I am going to have data caching. How can I get the 
c> ache updated (say per day?)

> (3) I try to find help in Trace=true and get following results. I get 
lost 
i> n some of points. First the Begin ProcessPostData Second Try and 
P> rocessPostData Second Try . Why it exists?

> Second I found that some components in the Control Tree with 
large "Render 
S> ize Bytes ". Am I going to minimize this size so that the page get 
faster?

> aspx.page Begin Init   
a> spx.page End Init 0.004144 0.004144 
a> spx.page Begin LoadViewState 0.004395 0.000251 
a> spx.page End LoadViewState 0.877411 0.873016 
a> spx.page Begin ProcessPostData 0.877841 0.000430 
a> spx.page End ProcessPostData 0.879132 0.001292 
a> spx.page Begin ProcessPostData Second Try 0.889182 0.010050 
a> spx.page End ProcessPostData Second Try 0.889630 0.000448 
a> spx.page Begin Raise ChangedEvents 0.889822 0.000193 
a> spx.page End Raise ChangedEvents 0.890053 0.000230 
a> spx.page Begin Raise PostBackEvent 0.890243 0.000190 
a> spx.page End Raise PostBackEvent 0.894263 0.004020 
a> spx.page Begin PreRender 0.894556 0.000292 
a> spx.page End PreRender 0.907754 0.013198 
a> spx.page Begin SaveViewState 5.251624 4.343870 
a> spx.page End SaveViewState 5.295165 0.043542 
a> spx.page Begin Render 5.295574 0.000409 
a> spx.page End Render 7.900519 2.604945 

> 
T> hanks a lot

> Kan

  Return to Index