next up previous
Next: Link-time Efficiency Up: Performance Previous: Templates

Smaller is Better

Software tends to expand to fill available memory, and programmers tend to judge their creations by the number of lines of code. There are two good reasons for worrying about program size, even when virtual memory is available and inexhaustible.

The most obvious reason to embedded programmers is that memory costs money and board space. Actually, it is the hardware designers who notice this first, and design in small amounts of memory. The programmer then asks for an additional 4Meg of flash memory and learns that 512Kbyte per chip means that 4Meg is 8 chips and the board just doesn't have that much space.

Large programs also tend to run slower. If it isn't simply because all those instructions take a long time to fetch from memory, it's because large programs overflow the instruction cache more often. Even dead code tends to spread the useful code into a larger address space and can lead to cache misses. Thanks to the widespread use of caches, memory and instruction, large programs are slow programs.

Stephen Williams
Sun May 4 15:28:26 PDT 1997