How to easily troubleshoot type instability traps in complex code?

I know that type stability is very important in Julia, so how can I get a warning when there is a type change in my code?

For example, I now have a very long code function f(x) that runs slowly, and I want to find out if there are some type conversion hidden in it that I didn’t find. Do you have any tools or advice to share on this?

Thank you for your attention!

@inferrred and @code_warntype are the go to tools for checking type stability. If there is type stability, Cthulhu is an interactive exploration tool for finding type stability problems (and lots of other problems)

2 Likes