Youâre getting somewhere. Now the Xc, Xd fields are still untyped; can you fix that?
Your mean alloc size is now ~40 bytes. That is exactly the size of a standard view. If this is correct, i.e. you mostly have views, then you need to think about getting rid of them.
If you determine that they impact performance, then you need to figure out which views are allocating (using julia --track-allocation) and do one of two things: Either add some @inline if possible, or remove the views by writing explicit loops instead of broadcasts.
Views only exist in order to permit people to be lazy about writing an API that uses AbstractVector. If you control the function you pass the view to, then you can change the API: For example, turn function some_fun(v::AbstractVector) into function some_fun(M::AbstractMatrix, row_id) and call it by some_fun(M, i) instead of some_fun(view(M, :, i)).
This is somewhat ugly. I think it is not recommended to crank out shitty APIs in order to work around the compiler / gc limitation that views sometimes allocate. Sometimes it is necessary, though. Afaict this limitation will stay with us for a while (when I last whined about it, I was told that this is due to lack of resources, different priorities, and carnaval stopping to work on it).
You can of course consider using unsafe views (pointer based); then you need to handle some memory management by hand.
The type of t is Tc but for integrator.u[end] I am not sure. @ChrisRackauckas Maybe I need to use a parametric call to create integratorlike integrator = init{Tc}(ODEProblem...)?
Maybe use a function barrier or do let integerator=integrator after you initiate it. Julia has some issues inferring all of the fields of it due to the keyword arguments, but in most uses like solve it hits a function barrier so we never really worried about this. If this is the big issue though we can try to better address this.