LWN.net Logo

Memory part 7: Memory performance tools

Memory part 7: Memory performance tools

Posted Nov 8, 2007 6:37 UTC (Thu) by njs (subscriber, #40338)
Parent article: Memory part 7: Memory performance tools

It's curious that Ulrich doesn't mention callgrind and its extraordinary front-end,
kcachegrind.  Stock oprofile and cachegrind are okay for programs written in a style where
each function is reasonably large and performs a relatively discrete task -- this seems to
include most traditional C programs.  But IME they become totally useless with, say, anything
written in C++, or really anything with many abstraction layers in it.  They tell you that,
say, you are suffering a lot of cache misses in your std::vector<>'s [] (element access)
operator -- which is fine, but tells you nothing about *which* of the thousands of call sites
in your source is actually causing the problem and should have its loops interchanged or
whatever.  Callgrind solves this problem, and kcachegrind makes call-graph data understandable
and usable.

Oprofile has a call-graph profiling mode too, but I at least find it very obscure (I only
managed to understand what it was measuring by asking the author on IRC).  Also, textual
output just doesn't cut it for this sort of thing, you really need some tools to visualize the
data.  So some might find useful a little script I wrote, that converts oprofile call-graph
profiles into something kcachegrind can read (see the oprofile manual to learn how to get
call-graph profiles): http://roberts.vorpus.org/~njs/op2calltree.py


(Log in to post comments)

Memory part 7: Memory performance tools

Posted Nov 8, 2007 20:41 UTC (Thu) by oak (subscriber, #2786) [Link]

Couldn't agree more. For profiling non-trivial programs (web browsers etc), GUI like Kcachgrind is a necessity. It helps also in comparing callgraphs from different use-cases. You want to understand bottlenecks in different use-cases and whether those bottlenecks are caused by same things. (optimizations are often compromises and you don't want to make a compromise you need to fix/revert later.)

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.