Google Performance Tools (profiler) tutorial - c++

I just downloaded and built the libraries/executables of Google Performance Tools. Before I run the CPU profiler on the application that I want to investigate, I want to learn how to use the tools properly perhaps on a sample application. What would be a good example to run the Google CPU profiler on? Thanks in advance.

The following paragraph appears in the README.windows file distributed with perftools 1.3:
The heap-profiler has had a preliminary port to Windows. It has not been well tested, and probably does not work at all when Frame Pointer Optimization (FPO) is enabled -- that is, in release mode. The other features of perftools, such as the cpu-profiler and leak-checker, have not yet been ported to Windows at all.

In my experience, for performance tuning, stack-sampling is the method of choice.
Google perftools contains a stack-sampler, and I believe its visual analyzer can be made to show the cost of individual statements, not just functions.
What you need to know is the percent of time the stack contains that statement, because that is how much time would be saved if the statement were removed.

Related

WCF Webservice slow, find bottleneck

I'm briefly familiar with SvctraceViewer, but I'm not sure that is the right tool for this. Problem is, I'm trying to work with a rather large WCF app, not designed nor developed by me. Also, it is poorly documented.
Some of the views are running slowly, but - I have no idea why.
Is there any program that I can use to find out where the bottleneck is?
How many milliseconds a task takes before completing and so on?
Just use any profiler. There's nothing magical about WCF services which requires a special tool.
I have used both the built-in profiler in Visual Studio and also the dotTrace product from Jetbrains to accomplish this.
+1 to John Saunders - a profiler is the way to go to diagnose your problem. Ants Profiler is also excellent. I think you can get a 15 day free trial - might be long enough to identify your problem

Find out where application is hanging

Is there a way to figure out where an application is hanging and not completing its function? I opened the call stack but it is empty. What does this mean. Does anyone have any advice for debugging where an application was the moment it started to hang/become non responsive.
Edit: I am using Visual Studio 2010
When this happens to me, I find attaching the Very Sleepy profiler to the debugee often makes it easy to identify where the hang occurred, even if you attach it after it happened - just look for stackframes that were active for 100% of the profiler sampling session (by sorting the list by the "Inclusive %" column and looking at the top).
Compile your application with all warnings enabled and with the compiler producing debugging information. On Linux, that means g++ -Wall -g. Work on the source code till you got no more warnings. Learn to use a debugger (e.g. gdb on Linux), and use its step by step abilities.
But we can't help you more, because this is system dependent and you did not tell what system you are using and you did not show us the code you are debugging.
Read How To Debug Small Programs
In addition to using the debugger, run a profiler through the code. My VS is rather rusty, so I can't give details on how to do so, but google can help.
It would also help to have many small functions instead of few large ones, as the tightest granularity of the profile is function level.
Put log statements into the code. It is time consuming but some sort of divide and conquer approach should help you solve the problem.

Windows Application Profilers - C++ Exe

I have a bat script which calls out to an exe and starts this off - I dont know what language it is written in (Probably C++)
I want to find a profiler that allows me to run a command a few times and gathers IO/CPU and other stats
It needs to be open source where possible
Any suggestions
You may try Performance Analysis of Logs (PAL) - http://pal.codeplex.com
It has predefined templates for major system metrics (see System Overview template).
It may automatically create quite impressive report including graphs and brief explanations on detected 'hotspots'.
I have used Glowcode (www.glowcode.com) in the past. It's not open source, but quite easy to use, can profile an executable, and is available on an evaluation basis as well.
I recall it was quite cheap as well.
For Windows, XPERF is your friend, and is a free download.
Check out the Windows Performace Analysis Tools site for more information on this and other tools.
Have fun!

Best way of adding SNMP support to your own application on Debian

I am working on Debian and I have this server we want to monitor.
The application is ours and there are around a hundred real-time counters we want to export for monitoring purposes, graphs and alarms.
I've been looking at the Debian way of doing this because we do use Debian packaging to install the app, and Debian uses snmpd daemon, based on net-snmp, to export SNMP.
So far every approach I've seen looks very complicated, from recompiling snmpd to load a dynamic library into it, and compiling a form of subagent that replicates what snmpd does.
While all of those options make me think I should go for something else than SNMP I don't want to give up that early and I was wondering if anybody has found a feasible implementation.
Ideally it should be coded in C or C++ as the app is in C++, but I'm open to wrappers or other kind of suggestions.
net-snmp supports both the smux and agentx agent extension protocols, allowing sub-agents to live in different processes. They also have a tutorial on writing AgentX subagents in C.
An often overlooked solution is Agent++ API, which to me looks pretty nice and is under the Apache license. As far as I understand, you can modify that agent to answer to your own MIBs.
That said, doing a subagent isn't such a bad choice. You start the standard unpatched snmpd (from net-snmp). Then you connect to it with your subagent, which only adds those OIDs you want it to add. The net-snmp kit for coding AgentX (as the protocol is called) sub-agents is not dead simple to use, but not very hard either. There is also a Perl module for sub-agent development: https://metacpan.org/pod/NetSNMP::agent
The traditional way to do this in linux is to use the net-snmp package. Make sure you write the MIB first. Everything is based on the MIB and changes to the MIB usually results in lots of changes in the code. Coding for net-snmp is not difficult and there is lots of documentation to get you started, eg: http://www.net-snmp.org/wiki/index.php/Tutorials#Coding_Tutorials
Have you tried net-snmp?

Continuous Integration: Unmanaged C++ on Visual Studio 2008

I've spent 4 years developing C++ using Visual Studio 2008 for a commercial company; it's now time for me to upgrade my development process.
Here's the problem: I dont have a 1 button build automation. I also dont have a CI server that automatically builds when a commit happens, and emails me whether a build is broken or not. Worse we dont even have a single unit test!!
Can someone please point to me how I can get started?
I have looked at many many tools and I think I might go with:
Visual Build (for build automation) (Note: I also considered Final Builder)
Cruise (for CI server)
I also now am just starting to practice TDD...so I will want to automate my unit tests as well. I chose Google Test/Mock for their extensive documentation. (Cant go wrong with Google brand can I? =p)
Price is not the issue, I want what's best and easiest to get started.
Can people that use real CI/automation tool for unmanaged MSVC++ tell me their tools and how I can go about starting?
Our source control is Subversion.
Last point: I'm also considering project management/tracking tool that integrates right into VSTD ..and thinking about using OnTime. VSTS costs too much. I tried FogBugz, but I think it's too simple. Any others?
I would take some time to seriously consider TeamCity. We used CruiseControl.NET for a while and TeamCity completely demolishes it. Plus it has built-in plugins for Boost and CppUnit, so your unit testing will come for free.
Best of all, the tool is free for < 20 users and gives you three build agents.
I just finished implementing our C++ product at work and it was fairly simple. We did it with msbuild and basically use the msbuild task to compile the solution. Other targets can be used to copy files, run unit tests, etc.
The last time I worked on an unmanaged MSVC++ project (which was moderately sized I might add), we used FinalBuilder to do the automated build & versioning (and even executing PCLint and other profiling tools as well).
Having said that, if you're willing to invest the time, MSBuild (or nAnt perhaps?) can do everything you need - even for unmanaged solutions.
Which brings us to the trade-off: Tools like Visual Build Pro and Final Builder get you up and running quickly. If you want something which offers a greater range of customization, you'll probably be spending a decent amount of time learning and understanding it - i.e. MSBuild, CIFactory, nAnt etc are no cake walk.
So if price isn't an issue - is time an issue? If time is at a premium, I'd investigate the GUI driven tools, they'll get you to where you want to go quickly. If you know you're going to need to extend on the simple one button build + unit tests + deploy scenario (which happens a lot!) then decide if you can invest the time into the more complex tools like MSBuild?
We use a combination of Boost.Build, NAnt, CPPUnit and either Cruise Control.NET or Hudson (we've used them both for various projects but are starting to prefer Hudson).
They are all good tools though we're considering replacing CPPUnit - the Google unit test system is pretty good from what I've seen.
If you're happy running on just Windows you can lose Boost.Build and just call out to Visual Studio from NAnt.
As for issue tracking/project management we settled on Vision Project after a long investigation. It's not well known (yet) but we've found it a very good fit in our environment. Fogbugz is great, a nice, clear interface but we came to the conclusion you did too; way too simple for our needs.
Although the .NET world is spoilt for these kinds of tools Continuous Integration is still pretty easy to set up for C++! I wouldn't think of starting a non-trivial project without putting these systems in place.
we use subversion + cruisecontrol + wix to accomplich CI automated builds outputting one-click installers. this combo has worked very well for us. we've created out own site for admin of svn user groups and permissioning and added the web interface to cc to it. we have a sql server storing all the collected stats from svn and cc and use them for custom reports available on our site. we are looking to add other tools to the mix for checking various attributes of the code stored in svn. this combo has worked very well for us.
At my company we use CruiseControl (http://cruisecontrol.sourceforge.net/). The Java version, not .NET, to build our wxWidgets application on Windows and OS X. Working great for us so far.