Inline Expansion - Problems

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:

    It is not impossible, of course, after such an administration as Roosevelt’s and after the change in method that I could not but adapt in view of my different way of looking at things, that questions should arise as to whether I should go back on the principles of the Roosevelt administration.... I have a government of limited power under a Constitution, and we have got to work out our problems on the basis of law. Now, if that is reactionary, then I am a reactionary.
    William Howard Taft (1857–1930)

    I have a horror of people who speak about the beautiful. What is the beautiful? One must speak of problems in painting!
    Pablo Picasso (1881–1973)

    In many ways, life becomes simpler [for young adults]. . . . We are expected to solve only a finite number of problems within a limited range of possible solutions. . . . It’s a mental vacation compared with figuring out who we are, what we believe, what we’re going to do with our talents, how we’re going to solve the social problems of the globe . . .and what the perfect way to raise our children will be.
    Roger Gould (20th century)