What is “overhead”?

前端 未结 12 1797
予麋鹿
予麋鹿 2020-12-12 09:24

I am a student in Computer Science and I am hearing the word \"overhead\" a lot when it comes to programs and sorts. What does this mean exactly?

相关标签:
12条回答
  • 2020-12-12 09:52

    Overhead typically reffers to the amount of extra resources (memory, processor, time, etc.) that different programming algorithms take.

    For example, the overhead of inserting into a balanced Binary Tree could be much larger than the same insert into a simple Linked List (the insert will take longer, use more processing power to balance the Tree, which results in a longer percieved operation time by the user).

    0 讨论(0)
  • 2020-12-12 09:54

    A concrete example of overhead is the difference between a "local" procedure call and a "remote" procedure call.

    For example, with classic RPC (and many other remote frameworks, like EJB), a function or method call looks the same to a coder whether its a local, in memory call, or a distributed, network call.

    For example:

    service.function(param1, param2);
    

    Is that a normal method, or a remote method? From what you see here you can't tell.

    But you can imagine that the difference in execution times between the two calls are dramatic.

    So, while the core implementation will "cost the same", the "overhead" involved is quite different.

    0 讨论(0)
  • 2020-12-12 09:55

    Overhead is simply the more time consumption in program execution. Example ; when we call a function and its control is passed where it is defined and then its body is executed, this means that we make our CPU to run through a long process( first passing the control to other place in memory and then executing there and then passing the control back to the former position) , consequently it takes alot performance time, hence Overhead. Our goals are to reduce this overhead by using the inline during function definition and calling time, which copies the content of the function at the function call hence we dont pass the control to some other location, but continue our program in a line, hence inline.

    0 讨论(0)
  • 2020-12-12 09:55

    its anything other than the data itself, ie tcp flags, headers, crc, fcs etc..

    0 讨论(0)
  • 2020-12-12 09:56

    It's the resources required to set up an operation. It might seem unrelated, but necessary.

    It's like when you need to go somewhere, you might need a car. But, it would be a lot of overhead to get a car to drive down the street, so you might want to walk. However, the overhead would be worth it if you were going across the country.

    In computer science, sometimes we use cars to go down the street because we don't have a better way, or it's not worth our time to "learn how to walk".

    0 讨论(0)
  • 2020-12-12 09:56

    For a programmer overhead refers to those system resources which are consumed by your code when it's running on a giving platform on a given set of input data. Usually the term is used in the context of comparing different implementations or possible implementations.

    For example we might say that a particular approach might incur considerable CPU overhead while another might incur more memory overhead and yet another might weighted to network overhead (and entail an external dependency, for example).

    Let's give a specific example: Compute the average (arithmetic mean) of a set of numbers.

    The obvious approach is to loop over the inputs, keeping a running total and a count. When the last number is encountered (signaled by "end of file" EOF, or some sentinel value, or some GUI buttom, whatever) then we simply divide the total by the number of inputs and we're done.

    This approach incurs almost no overhead in terms of CPU, memory or other resources. (It's a trivial task).

    Another possible approach is to "slurp" the input into a list. iterate over the list to calculate the sum, then divide that by the number of valid items from the list.

    By comparison this approach might incur arbitrary amounts of memory overhead.

    In a particular bad implementation we might perform the sum operation using recursion but without tail-elimination. Now, in addition to the memory overhead for our list we're also introducing stack overhead (which is a different sort of memory and is often a more limited resource than other forms of memory).

    Yet another (arguably more absurd) approach would be to post all of the inputs to some SQL table in an RDBMS. Then simply calling the SQL SUM function on that column of that table. This shifts our local memory overhead to some other server, and incurs network overhead and external dependencies on our execution. (Note that the remote server may or may not have any particular memory overhead associated with this task --- it might shove all the values immediately out to storage, for example).

    Hypothetically might consider an implementation over some sort of cluster (possibly to make the averaging of trillions of values feasible). In this case any necessary encoding and distribution of the values (mapping them out to the nodes) and the collection/collation of the results (reduction) would count as overhead.

    We can also talk about the overhead incurred by factors beyond the programmer's own code. For example compilation of some code for 32 or 64 bit processors might entail greater overhead than one would see for an old 8-bit or 16-bit architecture. This might involve larger memory overhead (alignment issues) or CPU overhead (where the CPU is forced to adjust bit ordering or used non-aligned instructions, etc) or both.

    Note that the disk space taken up by your code and it's libraries, etc. is not usually referred to as "overhead" but rather is called "footprint." Also the base memory your program consumes (without regard to any data set that it's processing) is called its "footprint" as well.

    0 讨论(0)
提交回复
热议问题