Sienna-Platform / Sienna-Platform/InfrastructureOptimizationModels.jl
Type-unstable hot loops
Open
@luke-kiernan is already working on this.
Since Aug 21, 2026.
performance
- Dominant language
- Julia
- Stars
- 1
- Forks
- 0
- Avg merge
- 8h 51m
- Merged PRs (30d)
- 9
Description
Address type-unstable hot loops. Things worth trying, or order of invasiveness:
- Introduce a function barrier. Replace
for d in devices # typeof(d) varies: loop body is type unstable.
# code here won't specialize.
end
with
for d in devices
_inner!(container, d, ...)
end
function _inner!(contrainer, d::D, ...) where {D}
# compiled per concrete D: code here will specialize
# (still a runtime dispatch, though)
end
If the loop body is sufficiently complex, and devices contains a couple different concrete types, the 2nd should win out. This may increase compile-time, though, so it's worth measuring.
- Add a replacement for
FlattenedIteratorthat unrolls across the different types. See IS #505. Requires interface work in IS (prototyped in that PR) plus rewriting the loops to usemapand similar.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.