Problems
Replacing a call site with an expanded function body can worsen performance in several ways :
- In applications where code size is more important than speed, such as many embedded systems, inlining is usually disadvantageous except for very small functions, such as trivial mutator methods.
- The increase in code size may cause a small, critical section of code to no longer fit in the cache, causing cache misses and slowdown.
- The added variables from the inlined procedure may consume additional registers, and in an area where register pressure is already high this may force spilling, which causes additional RAM accesses.
- A language specification may allow a program to make additional assumptions about arguments to procedures that it can no longer make after the procedure is inlined.
- If code size is increased too much, resource constraints such as RAM size may be exceeded, leading to programs that either cannot be run or that cause thrashing. Today, this is unlikely to be an issue with desktop or server computers except with very aggressive inlining, but it can still be an issue for embedded systems.
Typically, compiler developers keep these issues in mind, and incorporate heuristics into their compilers that choose which functions to inline so as to improve performance, rather than worsening it, in most cases.
Read more about this topic: Inline Expansion
Famous quotes containing the word problems:
“Hats have never at all been one of the vexing problems of my life, but, indifferent as I am, these render me speechless. I should think a well-taught and tasteful American milliner would go mad in England, and eventually hang herself with bolts of green and scarlet ribbonthe favorite colour combination in Liverpool.”
—Willa Cather (18761947)
“She has problems with separation; he has trouble with unityproblems that make themselves felt in our relationships with our children just as they do in our relations with each other. She pulls for connection; he pushes for separateness. She tends to feel shut out; he tends to feel overwhelmed and intruded upon. Its one of the reasons why she turns so eagerly to childrenespecially when theyre very young.”
—Lillian Breslow Rubin (20th century)
“Imagination is a valuable asset in business and she has a sister, Understanding, who also serves. Together they make a splendid team and business problems dissolve and the impossible is accomplished by their ministrations.... Imagination concerning the worlds wants and the individuals needs should be the Alpha and Omega of self-education.”
—Alice Foote MacDougall (18671945)