Cost of Abstractions in Embedded Systems
summary
Detailed case studies target an STM32 microcontroller, cross-compiled with GCC -Os and RTTI disabled, measuring binary size and loop iterations on hardware. Replacing C HAL patterns with templates and concepts and using consteval immediate functions moves bitmask and validation work to compile time, enabling compiler devirtualization and inlining. Results show about 2 KB saved (~20%) and ~20% faster loop throughput (4→5 iterations), and the talk pinpoints when static polymorphism or templated addresses beat static objects.
AI-written summary · about
chapters (17)
- 0:00Cost of abstractions
- 2:39Measuring abstraction costs
- 7:00Abstraction opportunities in hardware
- 10:33Encapsulation cost in registers
- 15:52Static functions and binary size
- 18:45Templated classes for overhead
- 19:50Inheritance without penalties
- 21:37Polymorphism overhead
- 27:43Dynamic polymorphism analysis
- 30:28Static polymorphism with concepts
- 34:01Firmware architecture performance
- 38:17Hardware abstraction inefficiencies
- 41:26Compile-time optimizations
- 44:38C++ compile-time validation
- 47:53Compile-time branching and bloat
- 50:42Benchmarking optimized vs original
- 52:06Key takeaways and C++ future
related talks
50mC++ Costless Abstractions: the compiler view
52mC++ for Embedded Development
01h 08mKeynote: What can C++ do for embedded systems developers?
01h 00mDealing with Embedded Limitations
53mOptimizing C for Microcontrollers - Best Practices
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 01mMicrocontrollers in Micro-increments...
01h 23mC++ Exceptions
