profiling in solaris - profiling

Can anyone suggest a good tool to profile a program compiled with SunCC compiler.
Also please suggest a good equivalent of valgrind for the same.

DTrace is the best tool for profiling [in] the universe.
DTrace is a comprehensive dynamic
tracing framework for the Solaris™
Operating Environment. DTrace provides
a powerful infrastructure to permit
administrators, developers, and
service personnel to concisely answer
arbitrary questions about the behavior
of the operating system and user
programs.
It's not marketing, it really allows just that.
The Solaris Dynamic Tracing Guide
describes how to use DTrace to
observe, debug, and tune system
behavior. The DTrace guide also
includes a complete reference for
bundled DTrace observability tools and
the D programming language.
DTrace is also available in Mac OS X, (there's a nice GUI for it, Instruments), and a FreeBSD port that has only kernel mode providers is also available.

The Sun Studio compilers include Performance Analyzer for profiling and Memory Runtime Checking features in the dbx debugger.
See also the answers to Locate bad memory access on Solaris.

On SPARC hardware, you may want consider IBM Rational Quantify for performance profiling.
On the cheap, you can get away with pstack sampling, prstat -vL, and instrumenting your application with gethrtime().

Related

Tool to count the miss rate of assembly

I want to speed up the execution of my code cpp and thought of looking at cache misses maybe I could change locality. So is there any such a tool? that would tell me the miss rate of every insns in assembly
Regards
Intel has such tools (VTune). valgrind is a free alternative. I seem to remember that IBM in the purify tools suite has also something for that.
Intel VTune (Windows & Linux)
AMD CodeAnalyst (Windows)
FWIW: If you have a particular system that you are targeting, it is possible that there might exist a simulator which will do this type of thing, but I think you would find in practice that the caching mechanisms vary so greatly from system to system that it would be very difficult to get a meaningful statistic.

resources for embedded projects

Can anyone suggest links/resources for sample project implementations of embedded projects using c++ or gcc.
Many resources are target specific, so you will have to be more specific if you want a specific answer. However http://embedded.com/ is a good general resource, and depending on your geographical location, you may qualify for a free subscription to Embedded Systems Design or Embedded Systems Design Europe paper publications.
Apart from Atmel AVR, GCC is targetted for 16/32bit targets, and C++ is generally ambitious and unnecessary for 8 bit, so I am guessing we are considering 16/32bit targets?
You might also take a look at:
Martin Thomas's ARM-Projects, including a GCC toolchain for Windows.
http://embdev.net/ which includes an embedded GCC forum.
Building Bare-Metal ARM Systems with GNU A description of bringing up a system using GCC with C and C++
FreeRTOS a well respected and widely used open-source RTOS kernel
eCos another open-source RTOS, but somewhat more than a scheduler kernel.
There are many many many resources....the question is too broad. Do you have a particular embedded micro you are targetting?
different embedded apps have different concerns
real time concerns?
extremely limited memory / resources?
OS? no OS?
Security?
Failsafe?
Device Drivers?
Question is incomplete, you have to provide all information, like product summary, hardware you want to use. But I guess you are porting some linux kernel to some embedded device.
For application program, easiest is to cross compile your code from your local system for specific arch and then transfer the binary to your embedded product.

What the best multi-thread application debugger for C++ apps

I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin.
The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars, etc.
It does not have to be an eclipse plugin or a free tool, do any of you have heard of something similar?
Qt Creator does provide information on a per-thread basis. It also has the features you would expect from any standard debugger. (Watches, breakpoints, etc.)
Although designed for compiling Qt applications, it can be used for just about any C++ project. (I have used it for compiling/editing a non-Qt app before.)
TotalView (and MemoryScape) doesn't do precisely what you're asking for in its' default presentation, but it provides the data you need. It costs money, but a better C++ debugger for Linux cannot be found.
Free trials are available, and there are a number of cool and useful videos on their support site.
If you're on linux, you've got access to one of the most powerful debugging tools in the trade - Valgrind. Read about it, especially about it's additional tools like Helgrind.
Sure, the visualisation is lacking compared to commercial tools, but you can't beat it's level of detail.

Performance profiling on Linux

What are the best tools for profiling C/C++ applications on *nix?
(I'm hoping to profile a server that is a mix of (blocking) file IO, epoll for network and fork()/execv() for some heavy lifting; but general help and more general tools are all also appreciated.)
Can you get the big system picture of RAM, CPU, network and disk all in one overview, and drill into it?
There's been a lot of talk on the kernel lists about things like perf timechart, but I haven't found anything turning up in Ubuntu yet.
I recommend taking stackshots, for which pstack is useful. Here's some more information:
Comments on gprof.
How stackshots work.
A blow-by-blow example.
A very short explanation.
If you want to spend money, Zoom looks like a pretty good tool.
For performance, you can try Callgrind, a Valgrind tool. Here is a nice article showing it in action.
Compile with -pg, run the program, and then use gprof
Compiling (and linking) with -pg adds profiling code and the profiling libraries to the executable, which then produces a file called gmon.out that contains the timing information. gprof displays call graphs and their (absolute and relative) timings.
See man gprof for details.
The canonical example of a full system profiling tool (for Solaris, OS X, FreeBSD) is DTrace. But it is not yet fully available on Linux (you can try here but the site is down for me at the moment, and I haven't tried it myself). There are many tools, in various states of usefulness, for doing full system profiling and kernel profiling on Linux.
You might consider investigating:
oprofile
SystemTap
bootchart
strace (e.g. this SO answer
Allinea MAP is a profiler for C++ and other native languages on Linux. It is commercially supported by my employer. It has a graphical interface and source-line level profiling and profiles code with almost no slowdown which makes it very accurate where timing of other subsystems is relevant - such as for IO.
Callgrind has been useful and accurate - but the slowdown was ~5x so I could only do smaller runs. It can actually count the number of times a function is called which is useful for understanding asymptotic behavior.
Description of using -gp and gproff here http://www.ibm.com/developerworks/library/l-gnuprof.html
oprofile might interest you. Ubuntu should have all the packages you need.
If you can take your application to freeBSD, OS X , or Solaris you can use dtrace, although dtrace is an analyst oriented tool -- i.e., you need to drive it -- read: script it. Nothing else can give you the level of granularity you need; Dtrace can not just profile the latencies of function calls in user-land; it can also follow a context switch into the kernel.
As mentioned in the accepted answer, Zoom can do some amazing things. I've used it to understand thread behavior all the way down to optimizing the assembly generated by the compiler.
The FOSS answer, as already mentioned, is to build with -pg and then use gprof to analyse the output. If it's a product/project that justifies throwing some money at, I would also be tempted to use IBM/Rationals Quantify profiler as that makes it easier to view the profiling data, drill down to the line level or look at it in a '10000ft' level.
Of course there might be viewer for gprof available that can do the same thing, but I am not aware of any.

C++ Code Profiler

Can anybody recommend a good code profiler for C++?
I came across Shiny - any good? http://sourceforge.net/projects/shinyprofiler/
Callgrind for Unix/Linux
DevPartner for Windows
Not C++ specific, but AMD's CodeAnalyst software is free and is feature-packed.
http://developer.amd.com/cpu/codeanalyst/codeanalystwindows/Pages/default.aspx
Gprof if you use gcc. It may not be user friendly but still useful.
Probably you will be interested in Intel VTune. Rather useful and allows to collect low-level events like cache misses which helps a lot in tuning.
Quantify (part of the IBM/Rational PurifyPlus package) is a very good profiler, but not exactly cheap. It is available on several platforms, too - I've used it on Solaris, Windows and Linux.
Depends on what you need to do:
Measure, so you can do regressions testing to see if changes in performance happened.
Find reasons for suboptimal performance and optimize them.
These are not the same.
For 1, use one of the recommended profilers.
For 2, the profiler I much prefer is one you already have:
http://www.wikihow.com/Optimize-Your-Program%27s-Performance
To see how this goes, check this out.
For C++, as for C# and any language that encourages layers of abstraction, those layers may or may not be good from a software engineering standpoint, but they can kill performance. Every method call is a detour in the execution of your program, and the style encourages you to nest those things, sometimes needlessly. Also the style discourages you from knowing or caring what goes on inside them. You may find them creating and deleting objects underneath at a rate and level of generality far beyond what your application really needs.
AQtime (for Windows)
If you are running a Premium version of VS 2010 then you get a profiler with it.
I've also used a couple of other free ones, but they don't compare to the on MS ships. Useful as a second opinion though.
If you have access to a Mac, then I recommend using Shark from the CHUD tools.
You can use the analyzer that´s in Sun Studio 12 on Linux or Solaris. Itś free. http://developers.sun.com/sunstudio/index.jsp
If you cannot locate DevPartner it is because we've moved under new ownership. Check us out on the Micro Focus website: http://www.microfocus.com/products/micro-focus-developer/devpartner/index.aspx. Shameless plug: I work on the DevPartner team. Our long awaited 64-bit versions of BoundsChecker and C++/.NET profilers ship on February 4, 2011. We've changed our pricing model so you can choose either the whole suite or just the performance profiler if that's what you need. Please check out the new DPS 10.5 release when it goes live!