Troubleshooting allocations in SymbolicUtils code

Hello!

I have some a model here that is having some performance issues. I’ve included below a screenshot of a performance profile:

As you can see, the majority of the time is being taken up by a macro expansion in SymbolicUtils.jl; as far as I can tell it is something about setting values in an array.

My question is, is this problem likely to be something wrong with my code, or something wrong with SymbolicUtils? If it’s something with my code, how should I go about debugging it?

Thanks for any help you can offer!

P.S. I do get this warning when I run the code:

┌ Warning: Using arrays or dicts to store parameters of different types can hurt performance.
│ Consider using tuples instead.

I am using a vector to store the parameters, but I was also doing that previously without a problem. Could that be what is causing the problem or is it likely unrelated?

I figured out the solution! It turns out that it was my code, and that the problem was that I needed to be using SymbolicIndexingInterface.jl to change the parameter values

1 Like

Yup SII has constructors to let you do the operations without any symbolic operations in the final code. It’s still a bit new (just had its first JuliaCon presentation this year) so not so many people know about it, but I highly recommend learning it if using MTK for performance applications. The MTK docs do make reference to it but likely not enough.

1 Like