Page 1 of 1

How to identify the performance bottleneck of the kernel?

Posted: Thu Apr 09, 2009 7:42 am
by zhongshu_gu
I am using bochs to run the os kernel and find the problem of low performance of fork.
How to identify the performance bottle neck in the bochs? It will be better if it can find which function or which source file waste most of the system time.
Thanks.

Re: How to identify the performance bottleneck of the kernel?

Posted: Thu Apr 09, 2009 9:01 am
by Creature
I guess the simplest (but probably longest one) is to simply time most of the functions called inside the 'fork' function. A very simple way of timing would be:

Code: Select all

unsigned long Time = GetSystemTicks();
DoFunction();
PrintValue(GetSystemTicks() - Time);
Or something equivalent. You can probably also measure it with the debugger or by profiling or something, but I'm not really sure how that works. You'll have to wait for some other responses I guess.

Re: How to identify the performance bottleneck of the kernel?

Posted: Thu Apr 09, 2009 9:46 am
by salil_bhagurkar
Unfortunately, the concept of a function that a compiler understands, is not understood by the processor. If it could, it would have generated exceptions on function entry and function exit, the handlers of which would take care of runtime profiling beautifully...

Re: How to identify the performance bottleneck of the kernel?

Posted: Thu Apr 09, 2009 10:46 am
by JamesM
salil_bhagurkar wrote:Unfortunately, the concept of a function that a compiler understands, is not understood by the processor. If it could, it would have generated exceptions on function entry and function exit, the handlers of which would take care of runtime profiling beautifully...
Have a look at -finstrument-functions. That should do EXACTLY what you want.

Re: How to identify the performance bottleneck of the kernel?

Posted: Thu Apr 09, 2009 12:26 pm
by salil_bhagurkar
JamesM wrote:
salil_bhagurkar wrote:Unfortunately, the concept of a function that a compiler understands, is not understood by the processor. If it could, it would have generated exceptions on function entry and function exit, the handlers of which would take care of runtime profiling beautifully...
Have a look at -finstrument-functions. That should do EXACTLY what you want.
Nice! This is interesting, but it will add a bit of memory overhead to your code. Apart from that, if you wanted to switch off the profiling, it would need a recompilation. Nevertheless, it would be a cool way to profile your code at runtime.