Small or fast?
Developers of software for desktop computers take code optimization for granted. Embedded developers typically need to pay much more attention to the details
Summary
Colin Walls' blog examines the trade-offs between minimizing code size and maximizing execution speed in embedded systems. Readers will learn practical techniques and decision criteria for optimizing firmware on constrained microcontrollers and how those choices differ when using RTOS or higher-level embedded Linux environments.
Key Takeaways
- Measure both size and performance using embedded-aware tools before changing code, and use profiling to find real bottlenecks.
- Use compiler and linker techniques (optimization levels, -Os/-O3, LTO, strip, and custom linker scripts) to control binary footprint without blind micro-optimizations.
- Prefer algorithmic and data-structure changes over local micro-optimizations to get the best size/perf wins.
- Apply architecture-specific features (ARM/RISC-V intrinsics, ABI choices, cache and alignment strategies) to unlock platform performance safely.
- Consider RTOS and embedded Linux impacts (scheduler overhead, context-switch latency, library choices) when balancing small vs. fast designs.
Who Should Read This
Intermediate firmware engineers and embedded software developers working with microcontrollers (ARM or RISC-V) and RTOS/embedded Linux who must balance code size and runtime performance.
Still RelevantIntermediate
Related Documents
- Consistent Overhead Byte Stuffing TimelessIntermediate
- PID Without a PhD TimelessIntermediate
- Introduction to Embedded Systems - A Cyber-Physical Systems Approach Still RelevantIntermediate
- Can an RTOS be really real-time? TimelessAdvanced
- Memory Mapped I/O in C TimelessIntermediate









