netsh interface ipv4 show subinterfaces
Debugging Assembly loading
How do I find all the ETW sessions on the machine?
logman is your tool for this. Here is how you can query for all the sessions and also how to see values from a particular session.
c:\> logman -ets
Data Collector Set Type Status
-------------------------------------------------------------------------------
AITEventLog Trace Running
Audio Trace Running
DiagLog Trace Running
EventLog-Application Trace Running
EventLog-System Trace Running
NtfsLog Trace Running
SQMLogger Trace Running
UBPM Trace Running
WdiContextLog Trace Running
MpWppTracing Trace Running
FSysAgentTrace Trace Running
MSMQ Trace Running
MSDTC_TRACE_SESSION Trace Running
test_trace Trace Running
The command completed successfully.
c:\> logman test_trace -ets
Name: test_trace
Status: Running
Root Path: C:\
Segment: Off
Schedules: On
Segment Max Size: 500 MB
Name: test_trace\test_trace
Type: Trace
Output Location: C:\09_19_44.etl
Append: Off
Circular: On
Overwrite: Off
Buffer Size: 8
Buffers Lost: 0
Buffers Written: 1
Buffer Flush Timer: 0
Clock Type: Performance
File Mode: File
Provider:
Name: Microsoft-Windows-Application Server-Applications
Provider Guid: {C651F5F6-1C0D-492E-8AE1-B4EFD7C9D503}
Level: 5
KeywordsAll: 0x0
KeywordsAny: 0xffffffff
Properties: 0
Filter Type: 0
The command completed successfully.Checkin #199390
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.
Linq over Excel
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.
public static DataTable GetData(string filename)
{
string fullPath = Path.GetFullPath(filename);
String conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
OleDbConnection cn = new OleDbConnection(string.Format(conn, fullPath));
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [Sheet1$]", cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
cn.Open();
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
static IEnumerable<T> GetData<T>(DataTable dt) where T : new()
{
PropertyInfo[] properties = typeof(T).GetProperties();
foreach (DataRow item in dt.Rows)
{
T o = default(T);
foreach (var property in properties)
{
if (dt.Columns.Contains(property.Name))
{
if (o == null)
{
o = new T();
}
property.SetValue(o, item[property.Name], null);
}
}
if (o == null)
continue;
yield return o;
}
}Here is an intersting project - http://code.google.com/p/linqtoexcel/
If you want to use an excel project you could do something like this.
Are connections pools shared between ChannelFactories?
You can find out about the connection Pool settings here and you can check Kenny's post on how connection pooling works.
How to synchronize multiple threads?
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
WaitForMultipleObjects helps synchronize multiple user mode threads.
“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.
using System;
using System.Threading;
using System.IO;
namespace TestThreading
{
class Program
{
const int ThreadCount = 10;
static ManualResetEvent[] events = new ManualResetEvent[ThreadCount];
static ThreadStart onStart = new ThreadStart(Start);
static int locked = -1;
static void Main(string[] args)
{
Thread[] threads = new Thread[ThreadCount];
for (int i = 0; i < ThreadCount; i++)
{
threads[i] = new Thread(onStart);
events[i] = new ManualResetEvent(false);
}
for (int i = 0; i < ThreadCount; i++)
{
threads[i].Start();
}
Console.ReadLine();
}
private static void Start()
{
int threadCount = Interlocked.Increment(ref locked);
Console.WriteLine("Thread {0} started & waiting", threadCount);
Thread.Sleep(3000); //Simulate some work befor setting.
events[threadCount].Set();
ManualResetEvent.WaitAll(events);
Console.WriteLine("Thread {0} proceeded", threadCount);
}
}
}How to collect stacks during context switches?
xperf –on base+cswitch+dispatcher –stackwalk cswitch+readythread
How to throttle callbacks or completions?
ServiceHosts & executing Operations from a crash/hang dump
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.


