Saving SRAM with 'no inline'


#1

Hi all,
it's been said before here and there, but only as part of other topics,
so I want to say it again, loud and clear and bright:
When you are using / writing code-heavy objects that will be used like >5 times
in a patch, it makes total sense to do the following:
- chop your code into functions, and tell axo's compiler NOT TO INLINE THEM
- collect it inside a 'master- object'
-refer to it from other 'slave - objects'.

code - snippet what I mean by not inlining:


I've attached a patch demonstrating the technique.
no inline.axp (11.4 KB)

..'no inline' will eventually hit your CPU a bit, but at k-rate not all that much, but can save a lot of SRAM.

I'm so ON about this because I noticed the factory table/save/load - objects are eating TONS of SRAM
when you are using more than 1 or 2 of them, probably because they also have a dependency to 'fatfs'
included.
so what I did was to tear apart the code and centralize them into a 'master-object',
they are now in the community library (rbrt/SD...)
I'll post something right away.


#2

Hi rbrt,
good idea.
it seems good. I think use it for some big repetitive patch. But I wonder if for objects defined by class c ++, it would work? given that a class instance contains its own data in addition to functions ...


#3

Hi @aRNo ,

...good question,honstely I don't know :thinking:
Actually, I'm not a 'trained' C++ - programmer,I just learn by doing with my axoloti.
However, 'attr_noinline' is just passing a directive to the compiler
not to inline (to inline == to replace every function call with the respective code),
so this makes the compiled program shorter and thus saves RAM.
I don't know how that relates to data.
hmmm.


#4

Methods in classes can be inline. Class scope is enforced by the compiler but does not apply to its output. Inline compilation is a scheme for avoiding call overhead (copying vars, setting up a stack and return address, etc.) for small methods. It's an instruction to the compiler for how to process the code, not a scope annotation.

Hope this helps,
John