How to identify the performance bottleneck of the kernel?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
zhongshu_gu
Posts: 6
Joined: Tue Jan 22, 2008 9:47 pm
Location: Beijing, China

How to identify the performance bottleneck of the kernel?

Post 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.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

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

Post 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.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

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

Post 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...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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

Post 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.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

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

Post 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.
Post Reply