0

I have a piece of ROS(c++) code that performs an optimization task and I encounter a problem where somewhere in the code there is a bottleneck which pushes a single CPU on which is operating to 100%, creating synchronization and delay issues with communications with other pieces of software. The code uses multiple threads at certain times (mainly for the heavy optimization part). I checked that piece of code using both console commands and the output of htop to tie the process to certain CPUs and I am fairly certain that the issue is not in the multithreading part. I am looking for different ways to track down the bottleneck reliably to either change it altogether or maybe multi-thread it. I have tried using gprof however the results (flat profile and call graph) do not show a strong indication on what the problem could be at least as far as I understand, which is not a lot since I have no experience with profilers and their output in general. I am attaching a small piece of the profiler's call graph output that might give an indication of what is going on to someone more experienced.

[cal graph

Geo
  • 56
  • 6
  • 1
    What is your question? Do you think it can be answered using the information you have provided in your post? – teapot418 Mar 02 '23 at 20:08
  • 1
    Your question is too general, but I can suggest you https://www.man7.org/linux/man-pages/man1/perf-record.1.html `sudo perf record ./program` and https://www.man7.org/linux/man-pages/man1/perf-report.1.html `perf report`/ it shows which assembly instruction called most frequently – Arseny Staroverov Mar 02 '23 at 21:21
  • @teapot418, I am not making a concrete question rather a general one asking for the ways other people approach the search for a bottleneck in their application. I gave a general description of my problem so that I get general answer I could try myself not necessarily solve my particular problem. I tried narrowing the question scope down by adding my OS type, programming language and middleware used. I am not sure what else I could include but suggestions are always welcome. – Geo Mar 03 '23 at 06:45
  • "someone more experienced" I've been solving problems like this for decades. [*This method*](https://stackoverflow.com/a/378024/23771) is what I would use. When there are multiple threads, I examine the call stacks of all of them at the same time, to see which ones are waiting for others, and why. – Mike Dunlavey Mar 03 '23 at 21:50

0 Answers0