Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do profiling with QEMU?

I am developing an OS (as a hobby) using QEMU and GDB but I'm now facing some performance issues. Therefore, I would like to know which functions should be optimized.

So basically, my needs are mainly to know:

  • In which functions my kernel is spending the most time.
  • How many times functions are called

Do you know how can I do that? I would accept a solution using Bochs too.

like image 731
Maxime Chéramy Avatar asked Jun 08 '13 12:06

Maxime Chéramy


1 Answers

As far as I can see, there is no web-based documentation available for QEMU profiling, although I would be very surprised if there was no way at all to do profiling. If QEMU is using kvm virtualization (as opposed to simulation), there might also be some profiling tools available specifically for kvm.

However, since QEMU provides access to GDB, you can still use that! The poor man's profiler uses GDB's backtrace periodically to figure out what all your threads are doing, which can be pretty helpful. This will give data about blocked threads as well as unblocked threads, but since you don't seem to know whether your performance problems are due to blocking or not, this should be much more useful than nothing. If you were feeling especially determined, you could use this data to create a more helpful visualization such as Brendan Gregg's flame graphs.

The worst (but usually easiest) technique is always going to be picking some random functions in the code which might be a bottleneck and outputting how long each call takes. Inelegant for sure, but mighty useful when nothing else is available.

like image 178
Dan Avatar answered Sep 23 '22 20:09

Dan