Friday, January 22, 2010

10 ASP.NET Performance and Scalability Secrets

10 ASP.NET Performance and Scalability Secrets should implement for sites that require improved performance.

For additional information on improving ASP.NET Performance click here.

Threat Analysis Tool

Threat Analysis Tool

Wednesday, January 20, 2010

WPF Threads

Learn about how WPF handles threads. WPF now offers two UI threads. Click on WPF Threads
and WPF Threading Model to learn more....

Memory Leaks with Delegates

When adding delegate (+=), you should remove it (-=) in order to release the delegate object and allow the GC to collect it. If a delegate maintains a reference to an externally declared object, and is not removed (-=), you will have a memory leak. For more details, click this article.

Thursday, January 7, 2010

Improve Garbage Collector Performance using Finalize/Dispose pattern

After reading an article that demonstrated how to improve GC performance (i.e., maximize size of Gen 0, minimize Gen 1 and Gen 2), I will refer to the Dispose pattern documentation on Microsoft site. The GC article is a good starting point and can be complemented by reading the Garbage Collection chapter in the "CLR via C#" book (i.e., where you will learn that large objects get placed directly on Gen 2 and more details not mentioned in this GC article).

It is very important to understand and implement the Dispose pattern correctly. If you do not, your application may do mysterious things, and it will not be the GC fault.

For details about Garbage Collector internals and more, read CLR via C# book (note in Feb 2010, Third edition of this book will be released).

For improving performance of your .NET applications check out the Microsoft Patterns and Practices.

Monday, January 4, 2010

SQL Server 2005 - Performance optimization with DMV

After reading a very interesting article on SQL Server 2005 optimization with DMVs, I want to share a sql script to identify the indexes (in a specific database used) that are very logically fragmented (i.e., require rebuild or reorganization to improve performance of sql queries). See details below:
-----------------------------------------------------------------------
/*
------------------------------------------------------
Purpose: Identifying Most Logically Fragmented Indexes
------------------------------------------------------
Details:
------------------------------------------------------
Logical index fragmentation indicates the percentage
of entries in the index that are out of order.
This is not the same as the page-fullness type of fragmentation.
Logical fragmentation has an impact on any order scans
that use an index. When possible, this fragmentation should be removed.
This can be achieved with a rebuild or reorganization of the index.
You can identify the most logically fragmented indexes using
the sys.dm_db_index_physical_stats DMV, which
lets you view details about the size and fragmentation of indexes.
This is joined to the sys.indexes DMV,
which contains details used in the creation of the index.
This script identifies the most logically fragmented indexes.
The results, which are sorted by the percent of fragmentation,
show the most logically fragmented indexes, and the database/table.
------------------------------------------------------
*/
DECLARE @dbid int;
select @dbid = db_id();
SELECT
DatabaseName = DB_NAME()
,TableName = OBJECT_NAME(s.[object_id])
,IndexName = i.name
,[Fragmentation %] = ROUND(avg_fragmentation_in_percent,2)
INTO #TempFragmentation
FROM sys.dm_db_index_physical_stats(@dbid,null, null, null,'DETAILED') s
INNER JOIN sys.indexes i ON s.[object_id] = i.[object_id]
AND s.index_id = i.index_id
WHERE s.database_id = @dbid
AND i.name IS NOT NULL -- Ignore HEAP indexes.
AND OBJECTPROPERTY(s.[object_id], 'IsMsShipped') = 0
AND avg_fragmentation_in_percent > 1
ORDER BY [Fragmentation %] DESC;

SELECT *
INTO Admin.dbo.[Most Logically Fragmented Indexes]
FROM #TempFragmentation
ORDER BY [Fragmentation %] DESC;
DROP TABLE #TempFragmentation;

---------------------------------------------------------------------------
For more information, check out the white paper on Performance Tuning Waits Queues.doc
---------------------------------------------------------------------------
For SQL Server 2008 DMV views click here