Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been experimenting a bit with some possible TTFX improvements.
In my tests these changes lead to an ~18% improvement in the latency for
ODEProblem, wich is the part that has the largest latency.Allocations:
Going a bit more into details, I lookd at
and profiled this with SnoopCompile and with Tracy. For the SnoopCompile case, though I noticed that the timings are much larger that what I get from
@time, so the inference times are a bit unreliable. I used that for the first commit, but I think we can drop it since the impact is minimal.The
nospecializechanges in the above table are the second commit.Based on the Tracy profiling the main issue is that we codegen a lot of methods
One thing to note is that we have a huge inference zone at the start, corresponding to the
ODEProblemconstructor. If we can somehow reduce the number of inference triggers or reduce the number of inferred methods, we can lower the JIT time since we'll have to compile less code. As I understand the main complexity is the recursive nature and the initialization system.I benchmarked the
solveafter this changes and runtime performance doesn't seem affected, but this is only one case. I'm not sure if things likeremakes during an optimization problem loop would be affected.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.