What optimization levels maybe -O1 or -O2 are typically used for balancing performance and code size

In my energy system project using embedded Linux, I'm curious about the trade-offs between code size and performance using compiler optimizations. I noticed the -O3 flag significantly reduces code size. Is it a common practice to use compiler optimizations like -O3 in embedded Linux development, especially for energy systems? What optimization levels maybe -O1 or -O2 are typically used for balancing performance and code size? Please Great house,help me out 🙏🙏
Solution:
@UC GEE optimization levels like -O1 and -O2 are more used in embedded systems, they provide a good balance between code size reduction and performance improvement. They optimize the code by applying various techniques such as instruction scheduling, loop unrolling, and function inlining. while the -O3 optimization level do provide better performance improvements, I won't advise you use it in embedded systems due to the potential increase in code size. as larger code size can lead to higher memory usage and potentially impact the overall system's energy consumption....
Jump to solution
4 Replies
Solution
Enthernet Code
Enthernet Code7mo ago
@UC GEE optimization levels like -O1 and -O2 are more used in embedded systems, they provide a good balance between code size reduction and performance improvement. They optimize the code by applying various techniques such as instruction scheduling, loop unrolling, and function inlining. while the -O3 optimization level do provide better performance improvements, I won't advise you use it in embedded systems due to the potential increase in code size. as larger code size can lead to higher memory usage and potentially impact the overall system's energy consumption.
UC GEE
UC GEE7mo ago
Ok, Thanks @Enthernet Code for your awesome Advice
Marvee Amasi
Marvee Amasi7mo ago
Especially for tight memory situations, even -O2 might be better.
UC GEE
UC GEE7mo ago
Oh... Thanks @Marvee Amasi ...I think this your point is another salient point 🙌
Want results from more Discord servers?
Add your server