Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreting gprof output with <spontaneous>

I am trying to find a performance issue in my program and thus instrumented the code with profiling. gprof creates a flat profile like this:

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 27.97      4.10     4.10                             std::_Deque_iterator<char, char&, char*>::_Deque_iterator(std::_Deque_iterator<char, char&, char*> const&)
  6.96      5.12     1.02                             std::_Deque_iterator<char, char&, char*>::difference_type std::operator-<char, char&, char*>(std::_Deque_iterator<char, char&, char*> const&, std::_Deque_iterator<char, char&, char*> const&)
  5.12      5.87     0.75                             std::__deque_buf_size(unsigned int)
  4.23      6.49     0.62                             std::_Deque_iterator<char, char&, char*>::operator+=(int)
  3.41      6.99     0.50                             std::deque<char, std::allocator<char> >::begin()
  1.91      7.27     0.28     7896     0.04     0.04  std::vector<MyClass, std::allocator<MyClass> >::_M_insert_aux(__gnu_cxx::__normal_iterator<MyClass*, std::vector<MyClass, MyClasst> > >, MyClassconst&)
  1.91      7.55     0.28                             std::deque<char, std::allocator<char> >::size() const
  1.91      7.83     0.28                             std::_Deque_iterator<char, char&, char*>::_S_buffer_size()

followed by many lines with less time.

First question: is it a valid assumption to believe that there seems to be a problem with a std::deque? The problem is: I know we are using std::deque, but I am not aware of a usage with <char>.

If this assumption is true, it seems to make sense to look at the call stack and see where this deque is used. Howevre all entries concerning the deque<char> stuff are only called by <spontaneous>!

Just one example:

index % time    self  children    called     name
                                                 <spontaneous>
[1]     28.0    4.10    0.00                 std::_Deque_iterator<char, char&, char*>::_Deque_iterator(std::_Deque_iterator<char, char&, char*> const&) [1]

Is there any way to find out more about this deque?

Thanks for any hints!

like image 640
Philipp Avatar asked Sep 30 '11 05:09

Philipp


1 Answers

Apparently, spontaneous is what gprof uses when it can't work out the calling function. I would try recompiling all code with -pg (is it possible you missed some files?). Also, make sure you have optimisation turned on. Inlining will typically make these little functions disappear into the calling function which is generally more useful.

like image 194
Bowie Owens Avatar answered Oct 07 '22 22:10

Bowie Owens