What is overhead?

Started by
5 comments, last by Sponge99 22 years, 8 months ago
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
"Now watch as I run away in a womanly fashion." - Batman
Advertisement
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
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...
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
-Mike
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.
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.
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.

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

This topic is closed to new replies.

Advertisement