28. 1) Go to Control panel’s
Power Options 2) Set to High Performance
•If you don’t do this, CPU is typically throttled to save power
•Throttling causes less consistent measurements
35. Related Sessions
Session Title Speaker Day Time Location
PC53 Lunch: Building High Performance JScript Apps Sameer
Chabungbam
Mon 12:45-1:30PM 515B
Microsoft Visual Studio: Bringing out the Best in Multicore Systems Hazim Shafi Mon 1:45-3:00PM 502A
WCF: Zen of Performance and Scale Nicholas Allen Tues 12:45-1:30PM 515B
SQL Server 2008: Developing Large Scale Web Applications and Services Jose Blakeley Tues 1:45-3:00PM 411
Using Instrumentation and Diagnostics to Develop High Quality Software Ricky Buch Tues 5:15-6:30PM 408B
TL24 Improving .NET Application Performance and Scalability Steve Carol Wed 1:15-2:30PM 153
Parallel Programming for Managed Developers with the Next Version of
Microsoft Visual Studio
Daniel Moth Wed 10:30-11:45AM Petree
Hall
HOL Code Title
TLHOL11 VSTS 2010: Diagnostics and Performance
Related Labs
43.
Select Columns
Working Set tends to Overestimates Memory Impact (shared OS files)
But does not account for read files. Private Working Set Underestimates Impact
Small < 20Meg WS Med ~ 50 Meg WS Large > 100 Meg WS
Small < 5 Meg Private Med ~ 20 Meg Private Large > 50 Meg Private
46. 1 Open .NET CLR Memory 2 Select Counters 4 Add 5 OK
3 Select Process
47. Set Display to Report GC Heap Size
So 7.3 Meg of the 8.6 Meg of private working set is the GC Heap
% Time in GC ideally less than 10%
Ratios of GC Generations Gen0 = 10 x Gen 1, Gen 1 = 10 x Gen 2
% Time in GC
48.
1 Total WS
2 Breakdown
3 DLL Breakdown
GC Heap Here
Only These Affect
Cold Startup
49.
In Either Case when Working Set Large (> 10Meg)
Throughput is lost due to cache misses
Server workloads are typically cache limited
56. Related Sessions
Session Title Speaker Day Time Location
PC53 Lunch: Building High Performance JScript Apps Sameer
Chabungbam
Mon 12:45-1:30PM 515B
Microsoft Visual Studio: Bringing out the Best in Multicore Systems Hazim Shafi Mon 1:45-3:00PM 502A
WCF: Zen of Performance and Scale Nicholas Allen Tues 12:45-1:30PM 515B
SQL Server 2008: Developing Large Scale Web Applications and Services Jose Blakeley Tues 1:45-3:00PM 411
Using Instrumentation and Diagnostics to Develop High Quality Software Ricky Buch Tues 5:15-6:30PM 408B
TL24 Improving .NET Application Performance and Scalability Steve Carol Wed 1:15-2:30PM 153
Parallel Programming for Managed Developers with the Next Version of
Microsoft Visual Studio
Daniel Moth Wed 10:30-11:45AM Petree
Hall
HOL Code Title
TLHOL11 VSTS 2010: Diagnostics and Performance
Related Labs
64.
6
4
int loopCount = 10;
for (int tId = 1; tId <= 3; tId++) { // Create three work items.
ThreadPool.QueueUserWorkItem(delegate
{
for (int i = 0; i < loopCount; i++)
{
Console.WriteLine("Thread i={0} time: {1}", i, DateTime.Now);
Thread.Sleep(1000);
}
});
}
Console.WriteLine("Waiting for workers. Hit return to end program.");
Console.ReadLine();
You can capture variables
Anonymous Delegate
68. Task task1 = Task.Create(delegate
{
Console.WriteLine("In task 1");
Thread.Sleep(1000); // do work
Console.WriteLine("Done task 1");
});
Task task2 = Task.Create(delegate
{
Console.WriteLine("In task 2");
Thread.Sleep(2000); // do work
Console.WriteLine("Done task 2");
});
If (userAbort) { task1.Cancel(); task2.Cancel(); }
Task.WaitAll(task1, task2);
Tasks now have handles
Exceptions in tasks propagated on wait
You can cancel work
You can wait on the
handle to synchronize
69. Future<int> left = Future.Create(delegate
{
Thread.Sleep(2000); // do work
return 1;
});
Future<int> right = Future.Create(delegate
{
Thread.Sleep(1000); // do work
return 1;
});
Console.WriteLine("Answer {0}", left.Value + right.Value);
Left and right
represent integers,
but they may not be
computed yet
Asking for the value
forces the wait if the
future is not already
done
In this case the right
value was done, so no
wait was needed
70. Loops
for(int i = 0; i < n; i++)
{
work(i);
}
foreach(T e in data)
{
work(e);
}
Parallel.For(0, n, i =>
{
work(i);
}
Parallel.ForEach(data, e =>
{
work(e);
}
74. Related Sessions
Session Title Speaker Day Time Location
Microsoft Visual Studio: Bringing out the Best in Multicore Systems Hazim Shafi Mon 1:45-3:00PM 502A
TL24 Improving .NET Application Performance and Scalability Steve Carol Wed 1:15-2:30PM 153
Parallel Programming for Managed Developers with the Next Version of
Microsoft Visual Studio
Daniel Moth Wed 10:30-11:45AM Petree
Hall
Parallel Symposium: Addressing the Hard Problems with Concurrency David Callahan Thurs 8:30-10:00AM 515A
Parallel Symposium: Future of Parallel Computing Dave Detlefs Thurs 12:00-1:30PM 515A
96. runat=“server”
Form:
<asp:DropDownList id="FileDropDownList" style="Z-INDEX: 111; LEFT:
192px; POSITION: absolute; TOP: 240px“ runat="server" Width="552px"
Height="40px“ AutoPostBack="True"></asp:DropDownList>
Code behind:
Private Sub FileDropDownList_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles FileDropDownList.SelectedIndexChanged
Session("FileSelected") = FileDropDownList.SelectedValue
End Sub
96
97. 97
IIS Architecture
User
Kernel
HTTP
TCP
IP
Network
Interface
HTTP Kernel Mode
Driver
(http.sys)
HTTP Response Cache
(Physical Memory)
LSSAS
Windows
Authentication
SSL
Inetinfo
IIS
Administration
FTP
Metabase
SMTP
NNTP
SVCHOST
W3SVC
W3wp
W3wp
Mscoree.dll
http
<code-behind>.dll
Default.aspx
Application Pool
W3wp
W3wp
Mscoree.dll
<code-behind>.dll
Default.aspx
Application Pool
WAS
Cache
net.tcp net.tcp
http
HTTP Request
98. 98
http.sys
Response object cache
Web Service
CacheKernel: Current
URIs Cached, etc.
See “IIS 7.0 Output Caching”
at http://learn.iis.net/page.aspx/154/iis-7-output-caching/
114. 114
UseUrlFilter to control the volume of data
Configure the TraceUriPrefix
See “How to Trace Requests for a
Specific URL or Set of URLs” at
http://www.microsoft.com/technet/pro
dtechnol/WindowsServer2003/Library/II
S/c56d19af-b3d1-4be9-8a6f-
4aa86bacac3f.mspx?mfr=true
116. 116
HttpContext.Request
HttpMethod (GET, POST, etc.)
URL
Cookies collection
Headers
InputStream
UserHostAddress (IP address of the Requestor)
etc.
The ASP.NET programming model provides several
facilities to persist User/Application state
117. Event Usage
PreInit Create dynamic controls, set the Theme; master page, etc.
Init Read or initialize control properties
InitComplete Raised by the Page object.
PreLoad Perform any processing on your page or control before the Load event.
Load The Page calls the OnLoad event method on the Page, then recursively for each
child control and its children
Control events Button Clicks and other Control events are processed after Page_Load
LoadComplete Fires after all controls on the page are loaded.
PreRender Data binding for controls occurs now.
SaveStateComplete Fires when the ViewState for all controls is complete and saved.
Render Method that writes out the html markup associated with the control.
Unload Do final cleanup, such as closing files or database connections
117
118. 118
Session State
Cache
e.g.,
Presentation Layer
Business Logic Layer
Data Layer
122.
State Management
ViewState Stored in _VIEWSTATE hidden field
ControlState Override if ViewState is turned off on the Page
HiddenField control
Cookies Add cookie data to the Cookies collection in the HttpResponse object
Query strings
Application State HttpApplicationState
Session State
Profiles SqlProfileProvider
122
125. 125
ViewState
Passed to the client in _ViewState hidden field in the
Response message
Returned to the Server on a postback Request
Inspect using
View html Source on the client
3rd party tools like Fiddler
Be careful of
Data bound controls (GridView, etc.)
Large TreeViews, DropDownLists, etc.
128. 128
ASP.NET Session state
HttpContext.Session
Data associated with a logical sequence of Requests
that need to be persisted across interactions
Unique session IDs are passed along automatically with
each Request as either cookies or embedded in the
URL
Session data is stored in a Dictionary collection,
allowing individual session state variables to be
accessed directly by Key name
Three external storage options
InProc
StateServer
SQL Server
Timeout management
129. 129
HttpContext.Session
InProc option provides fastest service, but does
not permit access to Session data from a
different process in a Web garden application
or a different Web server in a cluster
Using alternatives to InProc session storage has
significant performance implications
StateServer
SQL Server
Custom provider
Measure impact using the IIS
RequestNotification events
e.g., AcquireRequestState, PostAcquireRequestState
151. 151
When page caching will not work due to
dynamic content
[PartialCaching(120)] public partial class
CachedControl :
System.Web.UI.UserControl
// Class Code
Banner ads, etc.
152.
that did
not change
AJAX
Javascript asynchronous HTTP
requests
152
159. REST
AJAX library wraps asynchronous WCF service endpoints
Try the new Asynchronous WCF HTTP Module/Handler
for long running Requests
New in VS 2008 SP1
Releases the IIS worker thread immediately after processing
See Wenlong Dong’s blog for details
http://msdn.microsoft.com/en-us/library/cc907912.aspx
159