Thursday, December 14, 2017

ServiceStack is the future of Building Cross-Platform Web Services

ServiceStack is the current and future replacement to WCF, ASMX, MVC, MVC with Web API, Web API, SQL Server Web API, SQL Server HTTP Endpoints, Oracle Web Services, and other custom web service implementations for building cross-platform, client-agnostic, server-agnostic, web-service solutions.   I have used RestSharp client and ServiceStack web-services (on the server side) to create cross-platform, technology independent, micro-services implementations.   ServiceStack is AWESOME


The Flash traveling thru Space and Time, Stargate Portal, Wormhole

Thursday, March 3, 2016

SQL Server Index and Statistics Maintenance Scripts

SQL Scripts for index and statistics management which could help you manage SQL Server more efficiently and correctly.    Click here

Thursday, March 14, 2013

ContextSwitchDeadlock was detected

There is a bug in .NET RCW when frequently calling COM and/or COM+ components that use STA threading model.  The fix is to use the code from here.   In order to avoid the following error:


ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x16daf0 to COM context 0x16d8c8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over timeTo avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.




Tuesday, June 14, 2011

Fastest SQL Server Paging implementation

I found a great article that shows the fastest sql paging implementation. Click here to learn more.

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

Wednesday, October 21, 2009

C# Threading Issues

I just discovered an interesting article on Threading, by Jeffrey Richter. Thread synchronization does not work for unboxed value types.