Looking for some good optimization/profiling techniques...

edsut

Well-known member
Hi,
I've been using Teensy4.1 for a while. My most recent project requires more text space than available in ITCM, so I have to carefully place functions in ITCM space based on their frequency of use. This means I have a mix of functions some in external SPI flash and some in ITCM. Ideally, all my most frequently used functions would be in ITCM; plus there's the issue of veneer functions for cases when I am jumping between the two memory areas.
Assuming I have extra space (PSRAM) for logging results has anyone done any type of profiling (function counting or basic-block coverage) on Teensy4.1? If yes, any suggestions would be appreciated...
Tx
 
Hi,
Not for a teensy program but for a different controller running Forth language I have used a timer interrupt, that accumulates a histogram of the addresses of code that have been interrupted.
Cheers Christof
 
Not for a teensy program but for a different controller running Forth language I have used a timer interrupt, that accumulates a histogram of the addresses of code that have been interrupted.
Likewise, I don't know of any tools you could use to profile your code without changing your own code. I just design in counters and timestamps to track the number and duration of function executions.
 
Hi @edsut ,
did you consider to only place the text, not the whole functions into progmem (flash)?
  • PROGMEM & F() - Variables defined with PROGMEM, and strings surrounded by F() are placed only in the flash memory. They can be accessed normally, special functions normally used on 8 bit boards are not required to read PROGMEM variables."
from https://www.pjrc.com/store/teensy41.html .
 
Thanks for the replies. I have used a timer for this, but wanted to try something with per-function precision like the stuff that gcc supports with -p (IIRC). Years ago I did this, and yes it does cause a real-time hit on performance, but in this case I can deal with it. The issue that may come up with it is that it could cause the code to grow beyond the limits of ITCM space. Anyway, if I get something useful working I will post it here.
As I remember, there was the ability to compile in function counting as well as (more complex) basic-block-counting (which is probably more than I need). Honestly, that may have been pre-gcc, so I'll poke around and post what I find.
I don't run with the default Teensyduino stuff, so that kinda puts me a bit of a bind relative to this forum; but still... profiling is profiling.
 
Back
Top