Variables will always be on the stack or heap, so in ram. You only need to worry about marking code as in RAM.
Even with that, it seems like you should mostly worry about code in interrupt handlers or that otherwise might block progress across all the cores. There is a code cache that should keep your hot code in ram. The flash has a much higher latency than ram but to my understanding it can stream code for executing in place. This means you don't pay the penalty on every instruction, just on every jump to cold code.
To the extent you care strongly about performance, you have to benchmark. I don't know what the odds are that -Os or -O2 will be more efficient for you. Try it out!
Beware micro benchmarks though. Performance may not be representative.
Even with that, it seems like you should mostly worry about code in interrupt handlers or that otherwise might block progress across all the cores. There is a code cache that should keep your hot code in ram. The flash has a much higher latency than ram but to my understanding it can stream code for executing in place. This means you don't pay the penalty on every instruction, just on every jump to cold code.
To the extent you care strongly about performance, you have to benchmark. I don't know what the odds are that -Os or -O2 will be more efficient for you. Try it out!

Statistics: Posted by jags84 — Wed Apr 17, 2024 11:39 am