Search code examples
memory-managementcompiler-constructionvirtual-memory

Is there such a thing as "page optimization" in compilers?


I'm studying the basics of memory management and haven't found an answer for this.
Do the compilers, somehow, try to optimize the code in such a way that the pages are better read or used?


Solution

  • Many compilers will attempt to optimise the placement of loops so that the loop instructions are entirely contained within a single cache line, if possible. Similarly, attempts are often made to keep stack frames cache-line aligned.

    Since cache lines do not cross virtual page boundaries, such optimisations could also reduce the number of page faults. However, the main purpose is to avoid cache misses.