Archived

This topic is now archived and is closed to further replies.

Sponge99

What is overhead?

Recommended Posts

Sponge99    122
I''ve heard it everywhere over my 2 years programming, but never really knew what it was....can someone please enlighten me? (As to what function overhead is?) Thanks! -Sponge99

Share this post


Link to post
Share on other sites
dmounty    122
By the function overhead, we mean the cost (in terms of CPU/real time) for using the function. A function with a low overhead, uses little CPU time to setup, and hence may be used frequently, as its use carries little cost per use. A function with a high overhead may be used less frequently, as its use carries a large cost per usage.
By the way, the sort of times in which these functions setup is very short... ie a 700Mhz processors, runs 700,000,000 clocks per second, and setup may only take 20. But if you scale up these commands by a factor of 1,000,000 ie you ran them one million times, a considerable amount of time would be spent. The term overhead refers to the cost, but it is usually spoken of in relative terms, so a function to draw a scene in a realtime 3d engine may take 1/300 seconds to call, and this may be considered costly... however a preview in a 3D rendering package may take 1/20 second to setup, and not be considered costly, so the terms cost, and overhead are really to be taken in context, whether it be CPU cycles, milliseconds, seconds, minutes etc... hope this helps, if not, I hope it makes sense

Edited by - dmounty on July 29, 2001 10:13:51 AM

Share this post


Link to post
Share on other sites
Dactylos    122
Well, actually ''function overhead'' is the extra time spent when calling a function (besides the time spent in the actual function body, the code that you write). It''s time spent pushing parameters and performing the call-instruction, setting up a stack frame (if needed), and removing the stack frame and parameters when the function is done executing.

Most functions have the same amount of overhead (virtual methods have slightly larger overhead than usual functions though).

This is perhaps not the best description...

Share this post


Link to post
Share on other sites
Anon Mike    1098
Let me try...

Overhead is the stuff that needs to be done that isn''t directly related to want you actually want to do.

So for functions like above, it would be the cost of calling the fuction. For networking stuff it would be the headers vs the real data, etc.

-Mike

Share this post


Link to post
Share on other sites
gph-gw    122
If you have a function that''s > 32 bytes (> 64 on the P4) that''s called over and over again like this:

SomeFunc();
SomeFunc();
SomeFunc();

And there''s nothing in between the function calls, there''s almost no overhead because the cpu cache already has the function loaded - there''s no need to fetch it from memory. It''s a trick that takes patience to implement but with good payoff in some circumstances.

Using fastcall in VC++ or using inline asm and registers to pass arguments in other compilers also reduces the function overhead because there''s no push/pop to/from the stack.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Function overhead is the difference in time and resources between using a funtion normally and inlining the function. It involves things like adding parameters to the stack and maintaining function pointers and possibly a vtable if it is virtual. HTH.

Share this post


Link to post
Share on other sites
goltrpoat    122
Function overhead is when you''re reading someone else''s code and it totally goes over your head.

Sorry, couldn''t resist.

-goltrpoat


--
Float like a butterfly, bite like a crocodile.

Share this post


Link to post
Share on other sites