Tag Archives: Work

Does a referenced assembly get loaded if no types in the assembly are “not used”?The term used is is very subjective. For a developer it would mean that you probably never created an instance or called a method on it. But this does not cover the whole story. You can instead consider what are the reasons for an assembly load occurring. Suzanne’s blog on Assembly loading Failures would give you a good understanding of failures if that is what you are interested in. This post focuses on how to identify what exactly is causing an assembly to load.We in the WCF team are very cautious on introducing assembly dependencies and how how our code paths can cause assembly loads since this impacts the reference set of your process. Images that get loaded during a WCF call can become the cause of slow start up since every assembly is a potential disk look up and larger the number the higher the impact to startup. As a guidance for quick app startup is that you can eliminate a lot of the unnecessary assemblies from being loaded to speed up application startup if you refactor types properly. Continue reading →

Here is something for you performance guys. This was a hard one to crack but. Let me know what you think of this and how you would like to see this evolve. It will be a while before this is actually available.

Thanks to Wenlong for driving this all the way and for being our custodian for WCF/WF performance.

I was writing a tool and needed to quickly query an excel sheet. I’m not diving into linq but you get general idea of how to query/sort over the datatable and once you have an enumerable object you can pretty easily run a linq query over it.

In certain load tests you want to make sure a bunch of threads reach a particular state before they proceed with the rest of the work. You cannot make sure that all threads execute a point simultaneously since the CPU scheduling would determine this. However you can move these threads to Ready. A ready-thread is a thread can be scheduled for execution on a particular core – http://msdn.microsoft.com/en-us/library/dd627187%28VS.85%29.aspx

“The WaitForMultipleObjects function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses.”

Here is a small example of how to start multiple threads and then let them proceed after all of them have reached a particular point in execution.

With xperf being more and more adopted and with rich stackwalking capabilities, its only natural to use it for finding out bottlenecks and cause for switch out.

Findout the ready thread information and what causes the threads to switch out and the associated stack that woke up when a thread switches back in is one way to determine what was the offending stack that causes other threads to switch out. This helps us identify potential hot locks or just really expensive locks or issues due to false data sharing.

You can run the following command to capture stack traces with ready thread information.

WCF enables throttling execution of operations but not their completions. This becomes and issue when a large number of outstanding operations complete almost simultaneously causing the callback on the client to be overwhelmed with completions. Generally we don’t expect the client to issue of infinite number of pending operations but if you do end up with very high CPU usage and all suspect all your operations are stuck in the callback method which takes a lock then you need to throttle the callbacks yourself.You could try Setting the minThreads but this affects the whole app domain. The issue is due to the large number of callbacks that come in concurrently. The sample attached throttles the callbacks to have only one thread execute completions while there are 20 threads starting the operations and all completing almost simultaneously. The idea is to wrap the AsyncResult of your operation and complete only the required number of results in parallel and this would throttle the service operation Ends automatically.Sample Source: AsyncEndThrottling

Incase you are not sure of how to debug managed code with with a crash/hang dump, then you most likely need to read this first. Once you have SOS and mscordacwks(.net 3.5 and up) loaded you first dump the heap to find out if you have any services hosts at all.

We quickly find the method table entry for the ServiceHost type. We can get this from !dumpheap command as shown below. The following command helps to filter out just the types we are interested in.

!dumpheap –stat –type System.Servicemodel.ServiceHost

The next step is to dump all the ServiceHost using the method table entry shown above. The foreach command in the debugger helps us to loop through all objects that below to the type. .foreach(x {!dumpheap -short -mt 000007fef39ba7f0}) {!do x}

Our next step would be to find out how many calls are pending on the service. For this we can examine the ServiceThrottle on calls Field the service host. You can either use the instance value of the service throttle or offset. The following shows the call throttle and the count value in the flow throttle object would show how many services are being executed. The FlowThrottle is the object that holds the counters for the calls for the service.

In this case there is nothing executing so this dump was probably collected when there was no load. This is a quick way to identify if your service was actually executing any operations when collecting a process dump.