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:
“Our [adult] children have an adults right to make their own choices and have the responsibility of living with the consequences. If we make their problems ours, they avoid that responsibility, and we are faced with problems we cant and shouldnt solve.”
—Jane Adams (20th century)
“Our young people are diseased with the theological problems of original sin, origin of evil, predestination, and the like. These never presented a practical difficulty to any man,never darkened across any mans road, who did not go out of his way to seek them. These are the souls mumps, and measles, and whooping- coughs, and those who have not caught them cannot describe their health or prescribe a cure. A simple mind will not know these enemies.”
—Ralph Waldo Emerson (18031882)
“I had many problems in my conduct of the office being contrasted with President Kennedys conduct in the office, with my manner of dealing with things and his manner, with my accent and his accent, with my background and his background. He was a great public hero, and anything I did that someone didnt approve of, they would always feel that President Kennedy wouldnt have done that.”
—Lyndon Baines Johnson (19081973)