The good news is that TTFX has been steadily improving for a while.
One “trick” I would recommend is to organise your generic code into a Julia package proper - then that package and all its dependencies can be precompiled and cached. Even if your code needs to be recompiled, any heavy dependencies (DifferentialEquations.jl, plotting tools, etc) will load pretty much instantly.
You can then use Revise.jl to edit your package code live. In my own workflow, I have a neovim instance with a scratch file and a Julia REPL, then tab through files in the package to edit them. Revise reloads/recompiles these functions when they change without you having to touch anything. I keep Revise in my startup.jl file
.
I noticed there are also some tricks you can pull in your listed code. Julia has some very powerful metaprogramming and reflection tools. You can use these to e.g. query field names and look them up.
So e.g. this code:
@inline function logDke(t, x, dke::DKE)
return (
torque_B=copy(dke.torque_B),
force_B=copy(dke.force_B),
<...>
)
end
can be turned into a generic one-liner (including the copy):
log_struct(p) = (; (v=>getfield(p, v) |> copy for v in fieldnames(typeof(p)))...)
So this code
@inline simLog(x, t, integrator) = (
gncLog=logGnc(integrator.p.gnc),
dkeLog=logDke(t, x, integrator.p.dke),
senLog=logSen(integrator.p.sen),
actLog=logAct(t, integrator.p.act),
)
could become
@inline simLog(x, t, integrator) = (
x = x, t = t,
gncLog = log_struct(integrator.p.gnc),
dkeLog = log_struct(integrator.p.dke),
senLog = log_struct(integrator.p.sen),
actLog = log_struct(integrator.p.act),
)
(assuming you factor out any dependence on t and x in the original log calls).
This also means that if you change the fields of any structures, you don’t need to chase through your code to update all the logging functions
.
This discussion also discusses the use of generated functions (which lets you generate methods of functions specialised for particular types), which takes the cost of the call from microseconds to nanoseconds, if you’re into that kind of yak-shaving
.
Also, greetings from a fellow ECSS enjoyer! I’ve been meaning to put together a library to do PUS encoding/decoding for a while… hopefully will get to it next year!