Windows instrumentation profiling of native app tool - windows

Looking for something ideally as good as Visual Studio 2017 Diagnostic Tools CPU usage (while debugging very invaluable as one can profile the app between 2 breakpoints -> and you get profiling results in that interval) but for instrumentation. So I'm interested in function timings, no CPU usage in order to detect IO or other types of waitings in the app.

Concurrency Visualizer, an extension for Visual Studio fits the bill. It can report concurrency delays, one can see synchronisation points with the interthread dependencies, even has IO reported. A very goot tool, equivalent with Xperf for VS. Does not use instrumentation though, but because it exposes this synchronisation points it is more effective than instrumentation in concurrent apps.

Related

Wall clock analysis from Visual Studio Diagnostics Hub

The Performance and Diagnostics Hub in Visual Studio is an amazing feature. I use it for diagnosing Memory and high cpu issues while writing code. However, so far I am not able to figure out how to use this tool for troubleshooting low-cpu hang scenarios (or wall-clock analysis). Let's say my application takes long time on waiting a response back from a network or file I/O. Is there anyway of determining this from the Diagnostics windows in Visual Studio during a debugging sessions? I was hoping this analysis could be part of CPU Analysis section in there.
Like this blog here:
https://blogs.msdn.microsoft.com/devops/2014/02/28/new-cpu-usage-tool-in-the-performance-and-diagnostics-hub-in-visual-studio-2013/
The CPU Usage tool measures the CPU’s resources in terms of how much time each core in the CPU spends executing your code, it seems that it didn't provide the feature to resolve/collect the low-cpu hang issue.
Maybe you could think about using other tool like the PerfView or the suggestion of magicandre1981.
https://blogs.msdn.microsoft.com/vancem/2012/11/26/wall-clock-time-analysis-using-perfview/

How do I interact with Visual Studios native debugger when writing my own "mixed mode" debugger?

I've spent the last few days searching google, blogs and MSDN looking for any small scrap of info on how "interop" or "mixed mode" debugging is implemented in Visual Studio.
I'm attempting to implement my own debugger for a custom VM (actually, it gets JIT-ed to native code, which means I'll have to rebuild callstacks for the normal native debugger whenever it enter's the JIT-ed code), but I can't find any info on how you can actually interact with VS's native debugger and do the fancy "native/managed" like transitions that VS's mixed mode debugging pulls off.
So far I've found a few things that provide useful tidbits, but not enough to actually interact with the debugger. The best, most useful articles I've found are:
Mike Stall's various blog posts (mainly these two) while providing useful info and glimpses at the inner workings, they seem to be very heavily tied to .Net debugging.
MSDN's Creating a Basic Debugger gives a nice overview of how MS implements it's debuggers and how you can implement one on the same tech stack. Unfortunately, this doesn't really provide any real info on how to pass data off to VS's native debugger. (Combined with Mike Stall's blogs, it seems like both debuggers would be waiting for the same events, so how do you actually splice the results together in a meaningful way?)
The Debugger Engine API (aka DbgEng) documentation. I found this by running Dependency Walker on VS's native debug engine (NatDbgDE.dll, it seems to export the DebugCreate function which I could only find in this documentation, so it could be related). Unfortunately I've had very little success in even doing any debugging through this and it seems to be poorly documented, although the documentation does seem to indicate this is what I'll probably want to deal with in the end. It also doesn't really say how I can work cooperatively with another debugger and makes no mention of VS's debugger, so I could be going down the wrong path entirely with this anyway.
How can I get started with writing a debugger that will work cooperatively with VS's native debugger?
Thanks!
I'm afraid there's not much documentation on this subject. The resources you mention are all pretty old at this point. My suggestion is to integrate with Visual Studio's newer debug engine (Concord). Concord is used as the debug engine for native debugging from Visual Studio 2012 forward and for all debugging in Visual Studio 2013 forward. One of the design goals of Concord was to simplify mixed mode debugging. It is also designed to be easily extensible.
I created some Concord extensibility documentation that may be of help. It is mainly focused on expression evaluators, but it has some good information for getting started with Concord. Another resource that may be of use is the source code for the Concord-based debugger in Python Tools for Visual Studio. This is a full implementation of a mixed mode debugger that integrates with Concord and allows mixed mode debugging with Python.

visual studio 2013 concurrency visualizer tool. How to determine core load balancing

I am using the visual studio 2013 concurrency visualizer tool extension and i am trying to determine the workload of each processor with regards to tasks/threads. However, although there is a lot of data being produced, it seems slightly strange that there is no detailed data on core utilisation, only a CPU utilization graph which doesnt give me the info on a processes threads - just the main process. Yes, there is the threads tab which gives details on the threads but no info on core allocation... and the cores tab only provides info on context switching.
I have also tried the windows performance analyser to try and build up the data but that seems a dead end as well. Is there a way to get the data i need out these vs tools?
Have a look at the Concurrency Visualizer: http://msdn.microsoft.com/en-us/library/ee329530.aspx
It provides graphical views of CPU utilization, threads, and cores, which seems to be exactly what you are looking for.
It used to be part of the profiler in VS, but for VS2013 it's available as additional addin: http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/02/concurrency-visualizer-now-on-the-gallery-for-vs2013.aspx

How do you log all garbage collection events in CLR/.Net?

I'm looking for an equivalent of java -verbose:gc or any tool or code snippet to get the same information. Ideally, this would be something I could run in an unattended fashion on a service and log everything to a file. My use case is profiling GC-induced latency in a long-running service.
For noninvasive .NET GC profiling you have few options. You can either use CLR Memory Performance Counters or CLR Memory Event Tracing or some profiler (SciTech memory profiler has a nice command line tool that allows you to collect CLR profiling data in the production environment - other .NET profiles probably also expose such a feature).
I suppose that Performance Counters are the least invasive method, but they don't give you a detailed information on GC working - though you can see how many collections were performed (in each generation) as well as how much time your process spent in GC. To collect this information you may use perfmon, typeperf or Powershell (I once described different ways of using perf counters so you may have a look: http://lowleveldesign.wordpress.com/2012/04/19/diagnosing-applications-using-performance-counters/)
ETW events provide much more details on GC inner workings. You can configure the ETW provider manually (using logman or xperf for example) or use an excellent tool PerfView (as #Marc pointed in a comment). If you are only interested in GC events, check GC Only checkbox in the Collect windows:
There is a great episode of Defrag Tools dedicated to CLR GC profiling (part 4): http://channel9.msdn.com/Shows/Defrag-Tools/Defrag-Tools-36-CLR-GC-Part-4, I also recommend you checking the other parts as well as reading the PerfView documentation. PerfView is a really powerful tool and it even allows you to analyse .NET Heap and compare memory snapshots.
The last option (that is using a memory profiler) is probably the most invasive of the three methods, but sometimes might give you even more details on GC heaps (especially when you would like to analyse the objects graphs). I can't think of any good free GC Memory Profiler so probably you will need to pay to get one of those tools. I have some experience with SciTech Memory Profiler (it's pretty good and, as I mentioned earlier, they have a command line client that allows you to collect data on production). I also tried Visual Studio Memory profile - it's not bad but less powerfull than the SciTech one - and finally JetBrains and RedGate also sell memory profilers which are well know among .NET developers and probably comparable to SciTech.

Free .NET Profiler for .NET 4.0 mixed code

I checked out some of the performance profilers mentioned here. But...
EQATec didn't work for me because I have many assemblies I want to profile, and it has a limit on assemblies to profile. How much of a hassle is getting a free license? I'd go for it if someone guaranteed me that EQATec can profile both managed and unmanaged code
SlimTune only profiled my managed code, even if I set "Profile native functions" to "True"
XTE Profiler is no longer free
We have a copy of AQTime 6 we bought before, but it doesn't seem to support .NET 4.0 apps (it can't even start my app)
We use Visual Studio 2010 Professional SP1, so we don't have the Visual Studio profiler
I tried the "poor man's profiling" (halting the program many times and seeing where it is), but I get way too random results and I'm more used to traditional profiling
(I've spent the whole day stumped on this, sorry if I was too negative)
UPDATE: After I cleaned my solution, built it again and checked all debug info (.pdb) was copied to the same directory as the executable, I tried AQTime again and it worked! It showed me routine timing info for both managed and unmanaged code, so my problem is solved. However, I'm using a paid profiler, so the question will remain open until I take a look at xperf or someone comes up with something else
AQTime have a free version of their latest profiler (http://smartbear.com/products/free-tools/aqtime-standard/) It supports .Net 4, But I doubt it can do a mixed profile of Native and Managed.
If you are really serious about it you might look into the Microsoft xperf tools (http://msdn.microsoft.com/en-us/performance). They have a steep learning curve but they are free and I doubt any commercial profiler can do what xperf can (the instrumentation is in the OS, not in a separate process, thus either Vista, win7 or win2K8 are required). I'm waiting for someone to write a nice GUI around it, but it's taking a bit long... ;-)
xperf will profile your native code and you can load your symbols into the result viewer. I don't think it will go down to per-line granularity though. It has has a .Net CLR Provider (http://msdn.microsoft.com/en-us/library/dd264809.aspx). The cool thing about xperf is that it can also show other processes that may be influencing your performance (you are free to switch it off and only profile your own process). For example: it is capable of revealing that your IO is slow due to a badly written USB driver, virus scanner or firewall software. A traditional profiler would only show the slow IO, causing you to focus on a non-bottleneck.
By the way, there is also an ICorProfilerCallback interface you can utilize to write your own profiler (http://msdn.microsoft.com/en-us/library/s5ec0es1.aspx).
I' pretty sure the answer to your question is "There isn't one".
In comparing a whole bunch of .NET profilers a few months ago I found only very few could do mixed .NET/native profiling: AQTime ($599) and Glowcode ($499) could. Or so they say - I didn't try it.
EQATEC, Visual Studio, ANTS, Jetbrains dotTrace, Yourkit, XteProfiler, Slimtune etc could not, so I doubt you'll find a free profiler anytime soon that can.
CLR Profiler 4 by Microsoft is free. Have you tried it?
What do you look for in the unmanaged part of the profiler?
Your concern about EQATEC Profiler is easily resolved: it only does managed .NET profiling, not at all any kind of unmanaged profiling.
As shown in the pricing the actual profiling functionality differs only in the number of assemblies that can be profiled at once. So a $0 Free edition profiles a single-assembly WP7-app just as fine as a $999 Corporate edition does. For the extra price tag you get to profile more assemblies at once and a handful secondary features, like print, compare, min/max etc.
Getting a free license by trying out EQATEC Analytics is said to be easy. Going for the unlimited Corporate license is quite a popular choice and many have achieved it in just a couple of hours. Getting a free $99 Standard license shouldn't take more than 10 minutes or so, if you're good. Please note: I work at EQATEC and we actually hand out so many free licenses every day now that's it's almost become a burden because each is manually processed (yes, seriously!) so this particular offer may not go on forever.
OP: "I'd go for it if someone guaranteed me that XXXX can profile both managed and unmanaged code"
Our C# Timing Profiler is not dependent on how your C# code is compiled (managed or unmanaged, or mixed). It should work fine for this.

Resources