3

I am profiling some signal processing code using callgrind / qcachegrind involving many operations on std::vector<float>.

I'm getting quite a serious hotspot from the Mac OS builtin nearbyint function.

enter image description here

This seems to be called almost entirely by this vector function.

enter image description here

This in turn is called from many of my class member functions. To me, the _push_back_slow_path looks like some allocation bottleneck, but I'm not entirely sure why. At no point in the run loop am I changing the size of vectors. All that is happening, it occasionally they are copied by reference, iterated over, or the data() op is used to get the raw pointer for vDSP operations. For example . . .

enter image description here

  • Why is the vDSP function a culprit for this vector hotspot when I am passing it a raw data pointer?
  • What are the likely culprits for this hotspot?
  • Why is basic_string appearing? The profiled lib does not use strings.
  • Would switching over to std::array whenever possible be a wise next move?

Feel free to ask for any more info and I'll gladly edit the question.

EDIT 1

In response to the first answer, I am not explicitly calling push_back anywhere. The hotspots are occurring in seemingly bonkers places, such as this inlined log operation on a float. Could this be compiler optimization doing strange things?

enter image description here

learnvst
  • 15,455
  • 16
  • 74
  • 121
  • Produce annotated sources. Still, `_push_back_slow_path` seems to be called by your application, even if not by your code directly. – Maxim Egorushkin Mar 23 '16 at 12:28
  • 2
    If you try [*this*](http://stackoverflow.com/a/378024/23771) you will find out what's going on. – Mike Dunlavey Mar 23 '16 at 12:31
  • Mike, he has 19% of time here. How "poor man's sampling" may help him? Why do you think that your method is the only possible / best method of "profiling"? – osgx Jun 26 '16 at 14:57
  • learnvst, It looks like callgrind have wrong information about lines, log10 (C) will not call `std::` (C++). Try to recompile project with debug information, less optimization level (you may want to disable inline; you should disable omit-frame-pointer). – osgx Jun 26 '16 at 15:02

0 Answers0